有什么区别和功放的区别; VS @和=在angularJS [英] What is the difference between & vs @ and = in angularJS

查看:111
本文介绍了有什么区别和功放的区别; VS @和=在angularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的AngularJS。有谁能够给我解释一下其中的区别(安培;,@和=)分离适当范围,例如当。

I am very new to AngularJS. can anybody explain me the difference among these (&, @ and =) when isolating scope with proper example.

推荐答案

@ 允许在指令属性定义的值传递给指令的分离范围。该值可以是一个简单的字符串值( myattr =你好),或者它可能是一个AngularJS插值字符串嵌入前pressions( myattr =_我{{helloText}})。你可以把它看作是从父作用域到子指令单向交流。约翰·林德奎斯特有一系列短截屏解释其中的每。对@截屏是在这里:<一href=\"https://egghead.io/lessons/angularjs-isolate-scope-attribute-binding\">https://egghead.io/lessons/angularjs-isolate-scope-attribute-binding

@ allows a value defined on the directive attribute to be passed to the directive's isolate scope. The value could be a simple string value (myattr="hello") or it could be an AngularJS interpolated string with embedded expressions (myattr="my_{{helloText}}"). You can think of it as "one-way" communication from the parent scope into the child directive. John Lindquist has a series of short screencasts explaining each of these. Screencast on @ is here: https://egghead.io/lessons/angularjs-isolate-scope-attribute-binding

&安培; 允许指令的分离范围值传递到在属性中定义的前pression评估父范围。请注意,该指令属性是隐式的前pression并没有采用双大括号前pression语法。这一个是更严厉的文字来解释。截屏上和放大器;是在这里:<一href=\"https://egghead.io/lessons/angularjs-isolate-scope-ex$p$pssion-binding\">https://egghead.io/lessons/angularjs-isolate-scope-ex$p$pssion-binding

& allows the directive's isolate scope to pass values into the parent scope for evaluation in the expression defined in the attribute. Note that the directive attribute is implicitly an expression and does not use double curly brace expression syntax. This one is tougher to explain in text. Screencast on & is here: https://egghead.io/lessons/angularjs-isolate-scope-expression-binding

= 设置了指令的分离范围和父范围之间的双向绑定前pression。在子范围的变化,并传播到父,反之亦然。想想作为= @和与放大器的组合;.关于=截屏是在这里:<一href=\"https://egghead.io/lessons/angularjs-isolate-scope-two-way-binding\">https://egghead.io/lessons/angularjs-isolate-scope-two-way-binding

= sets up a two-way binding expression between the directive's isolate scope and the parent scope. Changes in the child scope and propagated to the parent and vice-versa. Think of = as a combination of @ and &. Screencast on = is here: https://egghead.io/lessons/angularjs-isolate-scope-two-way-binding

和终于在这里是显示在一个视图中同时使用所有这三个截屏:<一href=\"https://egghead.io/lessons/angularjs-isolate-scope-review\">https://egghead.io/lessons/angularjs-isolate-scope-review

And finally here is a screencast that shows all three used together in a single view: https://egghead.io/lessons/angularjs-isolate-scope-review

这篇关于有什么区别和功放的区别; VS @和=在angularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆