javascript - 关于ng指令隔离作用域的问题
阿神
阿神 2017-04-10 16:17:46
[JavaScript讨论组]

Outside myDirective:{{myProperty}}

Inside myDirective:{{myProperty}}

这是html的文件
下边是js的
1 scope=true

 .directive('myDirective',function () {
            return {
                restrict:'A',
                //scope:{},
                scope:true,
                priority:100,
                template:'

Inside myDirective {{myProperty}}

' }; });

ff下显示
Outside myDirective:
Inside myDirective wow,this is coll

2 scope {}

.directive('myDirective',function () {
            return {
                restrict:'A',
                scope:{},
                priority:100,
                template:'

Inside myDirective {{myProperty}}

' }; });

ff 下显示
Outside myDirective:wow,this is coll
Inside myDirective

scope:true; 将会创建一个新的作用域出来,所以本级可以读到myPropery上一级读取不到
scope:{},为甚么上一级可以读到!本级读取不到呢?

这个实在能晕了!不懂啊!请各位指点!谢谢

阿神
阿神

闭关修行中......

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号