search

Home  >  Q&A  >  body text

angular.js - How to add an attribute to an object in angularjs, in js?

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?

天蓬老师天蓬老师2784 days ago535

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-05-15 17:04:12

     
    $scope.bb.a = "sdfd";
    

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 17:04:12

    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.

    reply
    0
  • Cancelreply