我开始使用指令,现在我正在尝试使用权限级别呈现按钮。
假设我想渲染这个按钮
<a ui-sref="#" data-toggle="modal" data-target="#modalCadastro"><div id="addButton" class="btn btn-success">Add</div></a>
指示:
.directive('test', function($http){
$http.get('system/test/gettemplate')
.then(function(response){
if(response.data.success){ // small verification to know if it worked and i got a string with the template
$scope.template = response.data.template;
}
})
return{
restrict: 'AE',
scope:{},
template: $scope.template // which is my template that comes from back-end
}
})
我知道我错过了一些非常小的东西,但我是 Angular 的新手。