gpt4 book ai didi

javascript - AngularJS:将服务属性绑定(bind)到 Controller

转载 作者:行者123 更新时间:2023-12-03 08:26:13 24 4
gpt4 key购买 nike

我刚刚开始使用 ngJS。

我找到了将服务对象绑定(bind)到 Controller 的方法。

我想知道,这是实现此目的的良好做法还是有推荐的方法?

我还想知道为什么这只能在对象上实现,而不能在属性上实现?

这是我的 fiddle 。欢迎深入解释。

谢谢。

最佳答案

阅读此内容 SO thread .

A variable can hold one of two types of values: primitive values
and reference values
.

  • Primitive values are data that are stored on the stack.
  • Primitive value is stored directly in the location that the variable accesses.
  • Reference values are objects that are stored in the heap.
  • Reference value stored in the variable location is a pointer to a location in memory where the object is stored.
  • Primitive types inlcude Undefined, Null, Boolean, Number, or String.

The basics

Objects are aggregations of properties. A property can reference an object or a primitive. Primitives are values, they have no properties.

JavaScript has 5 primitive datatypes: string, number, boolean, null, undefined. With the exception of null and undefined, all primitives values have object equivalents which wrap around the primitive values, e.g. a String object wraps around a string primitive. All primitives are immutable.

关于javascript - AngularJS:将服务属性绑定(bind)到 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33538685/

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