1
我希望能夠在Angular客戶指令的鏈接函數內的範圍變量中設置一個變量的ng-show。從鏈接函數中指令範圍的變量設置角度的ng-show
angular.module('myApp')
.directive('testDir', function() {
return {
template: <div ng-show="{{showme}}"> hello </div>,
link: function (scope, element, attrs) { //
scope.showme=true;
}
});
不幸的是,當我這樣做時,它不能按預期工作。如果我設置scope.showme = true,那麼我的指令是隱藏的。如果我將它設置爲false,則顯示它。我怎麼搞砸了?