我创建了一个自定义指令:
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: "="
。 :) 如果您只需要字符串值,而不是作为title
内部作用域值,则可以使用title: "@"
。 - Kalhan.Toress