[英]AngularJS pass variable from custom directive to template
我做了一個自定義指令:
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屬性傳遞一些文本,然后我的模板將顯示文本。 我該怎么做?
非常感謝你 :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.