Issue
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_content
. Then, I populate on a texteditor(Froala) i'm using.
Below is the code for the view:
{{letter_content}}
<div ng-if="formData['page_number'] == 1 ">
{{letter_content}}
<textarea id="froala-sample-2" froala="froalaOptions" ng-model="letter_content"></textarea>
</div>
So basically I set letter_content
as ng-model for the texteditor. So when I make changes on the texteditor, it modifies the value $scope.letter_content
.
One thing I found it weird is that when I modify the text in the texteditor, it changes {{letter_content}}
inside the div. However, it does not update {{letter_content}}
outside the div.
When I'm done editing the text in my texteditor, I send send a put request to update the value in the database with $scope.letter_content
. However, it ends up sending {{letter_content}}
outside the div which ends up not updating the content.
Why is this weird thing happening?
Solution
Actually this has been discussed in more links.
Don't use primitive type variable. Instead of that use object in scope.
For example,
Don't use like $scope.primitiveVariale
instead of this $scope.object={primitiveVariale:null}
So in view use like object.primitiveVariale
then this will be reflect in all the view. Please see the following links.
https://github.com/angular/angular.js/wiki/Understanding-Scopes
Answered By - user4226210
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.