angularjs:在ui引导模式中使用指令
我不知道如何从使用$dialog服务创建的模式中调用指令。该指令还应该能够看到模式上的按钮,并覆盖其ng click操作 这是我的模式模板:angularjs:在ui引导模式中使用指令,angularjs,angularjs-directive,angular-ui-bootstrap,Angularjs,Angularjs Directive,Angular Ui Bootstrap,我不知道如何从使用$dialog服务创建的模式中调用指令。该指令还应该能够看到模式上的按钮,并覆盖其ng click操作 这是我的模式模板: <div class="modal-header"> <h1>Rechercher</h1> </div> <div class="modal-body"> <search-person></search-person> </div> <div c
<div class="modal-header">
<h1>Rechercher</h1>
</div>
<div class="modal-body">
<search-person></search-person>
</div>
<div class="modal-footer">
<button ng-click="close(result)" class="btn btn-primary">Close</button>
</div>
<span>{{test}}</span>
searchPerson控制器:
angular.module('person.controllers').controller('searchPersonCtrl', ['$scope', function ($scope) {
$scope.test = 2;
}]);
angular.module('person.controllers').controller('DialogController', ['$scope', 'dialog', function($scope, dialog) {
$scope.test = 2;
$scope.close = function (result) {
alert('modal scope');
dialog.close($scope.test);
};
}]);
最后是模态控制器:
angular.module('person.controllers').controller('searchPersonCtrl', ['$scope', function ($scope) {
$scope.test = 2;
}]);
angular.module('person.controllers').controller('DialogController', ['$scope', 'dialog', function($scope, dialog) {
$scope.test = 2;
$scope.close = function (result) {
alert('modal scope');
dialog.close($scope.test);
};
}]);
那么,如何使searchPerson控制器和modal控制器相互通信呢 我想我走得太远了。Modal不再是Modal的模板和控制器,也不再是内部的指令,Modal现在是该指令的模板。代码如下:
<div class="modal-header">
<h1>Rechercher</h1>
</div>
<div class="modal-body">
<!-- this used to be the searchPerson directive but now the Modal and the directive are just the same directive -->
<span>{{test}}</span>
</div>
<div class="modal-footer">
<button ng-click="close(result)" class="btn btn-primary">Close</button>
</div>
回收机
{{test}}
接近
我也遇到了类似的问题。这对你有用吗??