我创建了一个非常基本的Angular Directive
angular.module('starter.directives', [])
.directive('imageRotate', function(){
return {
restrict: 'A',
link: function(scope, elem, attr) {
console.log(1);
debugger;
elem.on('load', function() {
var w = $(this).width(),
h = $(this).height();
var div = elem.parent();
//check width and height and apply styling to parent here.
});
}
};
});
然后在我的控制器中显示以下模态
<ion-modal-view>
<ion-header-bar>
<h1 class="title"></h1>
<div class="buttons">
<button class="button button-clear" ng-click="closeLogin()">Cerrar</button>
</div>
</ion-header-bar>
<ion-content>
<img ng-src="{{img}}" style="width: 100%" imageRotate />
</ion-content>
</ion-modal-view>
我在初始模块声明中包含了模块starter.directives。
当我显示模态时,指令永远不会被执行。
这是我展示模态的方式
$ionicModal.fromTemplateUrl("../templates/galleryModal.html", {
animation: 'slide-in-up',
scope: $scope
}).then(function(modal){
$scope.modal = modal;
$scope.modal.show();
});
任何想法??