search

Home  >  Q&A  >  body text

angular.js - angularjs如何给对象加一个属性呢,在js中?

例如,我在jsp或者html文件中如此写一个作用域:
<input type="text" ng-model="bb.hello"/>

然后在js中,我如果想给bb添加一个属性该如何写呢?

在js中,如果直接写

bb.a="sdfd";
就回报错的。
那么该如何写符合这种东西呢?

天蓬老师天蓬老师2744 days ago508

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