Roc*_*645 1 angularjs angularjs-directive angularjs-scope
myApp.controller('myController', ['$scope', function($scope) {
$scope.a = 0;
$scope.find = function() {
$scope.a += 1;
}
}])
.directive('myLoading', [function() {
if ($scope.a % 2 === 0) {
return {
template: "<div>Hi</div>"
}
} else {
return {
template: ''
}
}
}]);
Run Code Online (Sandbox Code Playgroud)
我每次从按钮接收点击事件时都试图操纵DOM.这应该是每次我收到点击时在模板之间切换.但我在控制台日志中收到错误.$scope is not defined,指令中的那个.
| 归档时间: |
|
| 查看次数: |
1381 次 |
| 最近记录: |