gpt4 book ai didi

AngularJS 指令中的 locals 代表什么

转载 作者:行者123 更新时间:2023-12-01 03:57:18 26 4
gpt4 key购买 nike

AFAIK 这没有记录在案,但我在 angular 源中找到了 locals指令示例中的属性:

angular.module('transclude', [])
.directive('pane', function(){
return {
restrict: 'E',
transclude: true,
scope: 'isolate',
locals: { title:'bind' },
template: '<div style="border: 1px solid black;">' +
'<div style="background-color: gray">{{title}}</div>' +
'<div ng-transclude></div>' +
'</div>'
};
});
它有什么作用?我怎样才能使用它?
编辑
更准确地说:
我如何访问 locals来自 directive的 Controller 或 link功能?
如何动态更改 locals来自 directive的 Controller 或 link功能?
我可以用locals在每个指令中,还是必须是带有 transclude=true 的指令?

最佳答案

示例代码在 ngTransclude 上页面,里面script.js标签。

我相信这只是较旧的语法(似乎仍然有效)。较新的语法将取代

scope: 'isolate',
locals: { title:'bind' },


scope: { title: '@' },

关于AngularJS 指令中的 locals 代表什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16192974/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com