考慮到具有隔離範圍(對象)和限制A的指令,如何傳遞它們的屬性?例如,當涉及限制E時,如果範圍等於{attr:'@'},那麼該指令將被稱爲like。帶有限制的指令的屬性
0
A
回答
1
屬性可以像我們傳遞給E類型指令一樣傳遞。
參見:http://plnkr.co/edit/T2R91F0iR9GfttSav9Zq?p=preview
//HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example - example-example12-production</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-app="docsSimpleDirective">
<div ng-controller="Controller">
<div my-customer customer="customer" testv="Hello"></div>
</div>
</body>
</html>
//JS
(function(angular) {
'use strict';
angular.module('docsSimpleDirective', [])
.controller('Controller', ['$scope', function($scope) {
$scope.customer = {
name: 'Naomi',
address: '1600 Amphitheatre'
};
}])
.directive('myCustomer', function() {
return {
restrict: 'A',
scope: {
customer:'=',
testv: '@'
},
template: 'Name: {{customer.name}} Address: {{customer.address}} - {{v1}}',
link: function(scope, element, attrs) {
console.log(attrs);
scope.v1=attrs.testv;
}
};
});
})(window.angular);
0
同樣喜歡用限制è:
<div my-attr-directive attr="somevalue"></div>
1
當我們創建與限制 'E',這代表 '元' 指令,那麼它會調用等爲 -
<my-attr-directive attr="somevalue" ></my-attr-directive>
相關問題
- 1. 帶有{{}}指令屬性的角度
- 2. 屬性指令
- 3. AngularJS指令限制
- 4. 屬性的角度指令
- 5. 綁定指令控制器屬性
- 6. AngularJS指令屬性訪問控制器
- 7. 角2 HTML指令和屬性指令
- 8. 限制@RequestBody的JSON屬性
- 9. 如何在Vue.js中將屬性的範圍限制爲自定義指令?
- 10. C#屬性限制
- 11. 帶時間限制的Scons命令
- 12. 限制SSE指令集
- 13. 限制在角JS指令
- 14. 限制爲「允許」指令
- 15. AngularJS指令的屬性 - 使得可用的數組在指令
- 16. 帶有新屬性的xcdatamodel
- 17. 帶導航屬性的指定模式
- 18. 帶屬性和限制的XSD自定義類型
- 19. 帶屬性和最大長度限制的XSD元素
- 20. 忽略'optimize'屬性指令
- 21. 測試屬性指令
- 22. 事件指令中的限制參考
- 23. 作爲屬性的AngularJS指令 - 在指令中更改數組
- 24. 檢索指令的屬性動態地
- 25. Vue 2.0中的指令參數屬性
- 26. Angular指令設置禁用的屬性
- 27. 資源屬性內的動態指令
- 28. 什麼是屬性指令的例子
- 29. 測試angularjs指令的屬性
- 30. 手錶上的指令屬性