我做了一个自定义指令:
js部分:
angular.module("myDirectives", []).directive("ngShowbox", function(){
return {
restrict: "E",
scope: {
title: "="
},
template: "<a href='#' ng-click='show($event)'>{{title}}</a>",
controller: function($scope, $element){
$scope.show = function(event){
// do something...
}
}
}
});
html部分:
<ng-showbox title="whatToPutHere??"></ng-showbox>
我想从 title 属性传递一些文本, 然后我的模板将显示文本。 我怎样才能做到?
非常感谢:)
最佳答案
关于javascript - AngularJS 将变量从自定义指令传递到模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29384465/