Angular $scope variable not updating

后端 未结 6 1500
一整个雨季
一整个雨季 2021-01-02 04:19

In my angular, I define a scope variable $scope.letter_content. When the view is loaded, I load string from my database and set it to $scope.letter_conten

6条回答
  •  没有蜡笔的小新
    2021-01-02 04:44

    The ng-if directive create a new scope, so the letter_content inside the div is in the ng-if scope, but the letter_content outside is in the controller scope.

    Read the API doc to know which directive create new scope.

    To avoid this kind of problem consider using the controllerAs syntax

提交回复
热议问题