angular.js - How to add an attribute to an object in angularjs, in js?
天蓬老师
天蓬老师 2017-05-15 17:02:12
0
2
522

For example, I write a scope like this in a jsp or html file:
<input type="text" ng-model="bb.hello"/>

Then in js, if I want to add an attribute to bb, how should I write it?

In js, if you write directly

bb.a="sdfd";
Just report the error.
So how to write something that fits this kind of thing?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
大家讲道理
 
$scope.bb.a = "sdfd";
Ty80

As far as writing is concerned, if a variable in HTML, such as bb, reaches the controller, it needs to be preceded by $scope., which is $scope.bb.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template