
两个不同的DIRECTIVE如何取对应scope中的值
JS代码
.directive('save',function(){
return{
restrict:'EAC',
template:'
',
scope:{ goodsName: '@goodName'},
link:function(scope,element,attrs){
var childElem = element.find('toggleName');
var childScope = childElem.isolateScope();
element.on('click', function() {
var jsonData = scope.goodName;
alert(jsonData);
});
}
};
});
.directive('toggleName', function() {
return {
restrict: 'ECA',
templateUrl: 'views/partials/toggleName.html',
transclute: true,
link: function(scope, element, attrs) {
scope.toggleName = function() {
scope.isSuccessName = !scope.isSuccessName;
};
}
};
})
HTML代码
save取togglename中的goodName
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
使用require就搞定了