場景:
controller擷取指令值
僞代碼如下:
示例:
AmqConfigController
$scope.testname = null; //注意,這個是必須添加的,否則輸出時出現undefined
$scope.saveOne = function(saveEsbAmqconfig) {
console.log("model==================="+saveEsbAmqconfig.sender);
console.log("testname==================="+$scope.testname);
}
jsp
<div class="col-md-9 col-md-offset-1" data-ng-controller="AmqConfigController">
<input type="text" class="form-control" test-name="testname" name="senderName" data-ng-model="saveEsbAmqconfig.sender" data-person-directive="">
</div>
指令
app.directive( 'personDirective',['UrlManager','$modal',function(urlManager,$modal){
return {
restrict : 'ECAM',
scope: {
testName: '=',
ngModel: '='
},
link: function(scope,elem,attr){
elem.bind('click',function(){
$modal.open({
templateUrl : urlManager.$staticViewUrls.$getUrl( 'static/esb/html/amqconfig/option-view' ),
backdrop : 'false',
controller : ['$scope', '$modalInstance','PlatformService',function($scope,) {
scope['testName']=JSON.stringify("name-------------");
scope['ngModel']=JSON.stringify("ngModel---------");
});
$scope.testname = null; //注意,這個是必須添加的,否則輸出時出現undefined,因為scope裡面找不到這個屬性,~~~~~~~~~~~~~找了快一天的原因了, 結果還是同僚幫忙搞定,哭了。。。。。。。。。