0
嗨我試圖控制基於內部指令的值的HTML。在我的情況下如何從指令發送數據到父控制器?
我有這樣的HTML:
//myCtrl.isLoad was set to false
<img ng-src="{{myCtrl.url}}" imageonload></img>
<div ng-if="myCtrl.isLoad">Show me</div>
指令:
angular.module('myApp')
.directive('imageonload', imageonloadFunction);
function imageonloadFunction() {
var directive = {
'link': link,
'restrict': 'A'
};
return directive;
}
function link($scope, element, attrs) {
some other codes..
//Do something if the condition is met
//and change myCtrl.isLoad = true so
//<div ng-if="myCtrl.isLoad">Show me</div>
//will show
}
我不知道的最好方式指令數據綁定到父。任何人都可以幫助我嗎?非常感謝!
你必須到'myCtrl.isLoad'變量傳遞給指令...'