這是我的問題,我想將帶有模板的指令應用於頁面上的元素,並在其上增加值。Angular指令模板上的增量值
我的問題是我的值保持在0,我在stackoverflow上嘗試了很多答案,但沒有成功與他們,我很新的角度。
這裏是我的指令:
app.directive('loader', function ($window) {
return {
restrict: 'E',
replace: true,
transclude: true,
controller: function($scope){
if (!$scope.counter)
$scope.counter = 0;
else
$scope.counter++;
},
template: '<div ng-class=\"({ \'display-opacity\' : ready{{counter}} })\" ng-transclude></div>',
};
});
的要求,這裏是我的哈巴狗模板:
loader
| test
loader
| test
你能告訴我們你的html,你在哪裏「調用」這個指令? – Brakebein
編輯顯示模板 – Sunkhern
和'裝載機 |測試「結果到什麼HTML? (對不起,我不知道帕格)。但我想,現在我明白你想達到的目標。 – Brakebein