0
我建立了一個指令,但不在頁面上顯示?這是代碼:如何顯示角度指令?
app.directive('resetFilter', function() {
return {
restrict:'E',
template:'<div> This is the filter: <a href="#" ng-click="resetFilter()">Reset Filter</a> </div>',
controller:function($scope){
$scope.resetFilter= function(){
console.log('resetfilter this one !!!!');
$scope.name=''
console.log('accname',$scope.name);
};
}
};
});
HTML如下:
<body ng-controller="MainCtrl">
<reset-filter></reset-filter>
name: {{hello}}
<input type="text" ng-model='hello' />
</body>
此外,我怎麼能觸發resetFilter功能?我想重置$ scope.name的值? plunk: http://plnkr.co/edit/rUCMq9?p=preview
@Pindakaas如果你仍然無法弄清楚。你可以查看這個http://plnkr.co/edit/NjpjO18qH53QQv0LW811?p=preview。 – kdlcruz
很酷的傢伙 – Pindakaas