【发布时间】:2016-04-06 15:06:38
【问题描述】:
我正在阅读来自此 url https://docs.angularjs.org/guide/directive 的指令的一篇文章
The restrict option is typically set to:
'A' - only matches attribute name
'E' - only matches element name
'C' - only matches class name
'M' - only matches comment
<div ng-controller="Controller">
<my-customer></my-customer>
</div>
angular.module('docsRestrictDirective', [])
.controller('Controller', ['$scope', function($scope) {
$scope.customer = {
name: 'Naomi',
address: '1600 Amphitheatre'
};
}])
.directive('myCustomer', function() {
return {
restrict: 'E',
templateUrl: 'my-customer.html'
};
});
模板html文件
Name: {{customer.name}} Address: {{customer.address}}
请帮我理解 restrict: 'E', ?
是什么意思我正在寻找一个限制为 A 或 C
的示例请告诉我限制的用法:'A'和C
还告诉我如何将多个参数传递给指令?
谢谢
【问题讨论】:
-
所以你已经发布了答案和问题。什么你不明白 - 它是视图内部指令实际实现的一部分吗?
标签: angularjs