重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

AngularJs1.x自定义指令独立作用域的函数传入参数方法-创新互联

在定义指令的scope属性如果设置成了{},那就成为了一个独立作用域,如果要传入一个方法,使用&,但是这里的传参有点不一样。

在茂名等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、成都网站制作、外贸网站建设 网站设计制作定制设计,公司网站建设,企业网站建设,成都品牌网站建设,成都全网营销,外贸网站建设,茂名网站建设费用合理。

先看下官网解释:

& or &attr - provides a way to execute an expression in the context of the parent scope. If no attr name is specified then the attribute name is assumed to be the same as the local name. Given and widget definition of scope: { localFn:'&myAttr' }, then isolate scope property localFn will point to a function wrapper for the count = count + value expression. Often it's desirable to pass data from the isolated scope via an expression and to the parent scope, this can be done by passing a map of local variable names and values into the expression wrapper fn. For example, if the expression is increment(amount) then we can specify the amount value by calling the localFn as localFn({amount: 22}).

这里有个例子:




 
 


{{item|json}}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


本文题目:AngularJs1.x自定义指令独立作用域的函数传入参数方法-创新互联
当前URL:http://cqcxhl.com/article/dhcgos.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP