【发布时间】:2015-03-04 00:20:24
【问题描述】:
我有这部分代码,其中第二个 <tr> 仅在“编辑”单击时出现,并出现一个我正在使用指令显示的表单。
<table class="table">
<tbody ng-repeat="Emp in Employees">
<tr>
...
<td>
<input type="button" class="btn btn-default" value="Edit" ng-click="isCollapsed = !isCollapsed" />
</td>
</tr>
<tr collapse="isCollapsed">
<td>
<div>
<employee-form></employee-form>
</div>
</td>
</tr>
</tbody>
</table>
现在我的employeeForm 指令中也有一个按钮,单击该按钮会使该表单消失(isCollapsed=true)。但不知何故,这不起作用。
员工表单的标记:
<form>
...
<button type="button" class="btn btn-default" value="Cancel" ng-click="isCollapsed = true" />
</form>
对此的JS部分是:
$scope.isCollapsed = true;
所以我想要的是点击employeeForm 中的Cancel 按钮,<tr> 应该消失。
【问题讨论】:
-
发布
employee-form指令代码。 -
app.directive('employeeForm', function () { return { restrict: 'E', templateUrl: '/Scripts/Employee/Form.html' } }); -
你试过
<button type="button" class="btn btn-default" value="Cancel" ng-click="isCollapsed = false" />吗?
标签: angularjs twitter-bootstrap angularjs-directive collapse