我想使用 ng-show 指令显示和隐藏按钮。
这是我的HTML 文件:
<button class="btn btn-info" ng-show="editBtn">Save Edit
<span class="glyphicon glyphicon-ok"></span>
</button>
这是我的controllerScript 文件:
myApp = angular.module("myApp", []);
myApp.controller ("epmloyeeCtrl", ["$scope", function($scope){
$scope.editBtn = false;
}]);
最佳答案
我认为您忘记了 HTML 中的 ng-app
或 ng-controller
。应该是:
<div ng-app="myApp">
<div ng-controller="epmloyeeCtrl">
<button class="btn btn-info" ng-show="editBtn">Save Edit
<span class="glyphicon glyphicon-ok"></span>
</button>
</div>
</div>
Controller :
var myApp = angular.module("myApp", []);
myApp.controller ("epmloyeeCtrl", ["$scope", function($scope){
$scope.editBtn = false;
}]);
我有关于您的代码中的显示/隐藏编辑按钮
的演示:Here!
关于javascript - angularjs ng-show 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37642780/