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}}

以上这篇AngularJs1.x自定义指令独立作用域的函数传入参数方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持创新互联。


文章标题:AngularJs1.x自定义指令独立作用域的函数传入参数方法
文章地址:http://hxwzsj.com/article/ppcjoo.html

其他资讯

Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14
友情链接: 重庆网站设计 营销型网站建设 成都网站建设推广 重庆网站建设 高端网站设计 成都网站建设 成都网站设计 成都网站制作 高端网站建设 成都网站制作 响应式网站设计方案 重庆电商网站建设 成都商城网站建设 成都企业网站建设 成都品牌网站设计 营销型网站建设 网站制作公司 响应式网站建设 成都网站制作公司 网站建设改版 网站建设方案 成都网站制作