How do you implement one-way binding? Please provide some explanation on why and when you would use one-way binding.
I'm new to AngularJS.
How do you implement one-way binding? Please provide some explanation on why and when you would use one-way binding.
I'm new to AngularJS.
Please provide some explanation on why and when you would use one-way binding.
Possible Reasons:
How do you implement one-way binding?
Before Angular 1.5 you can make a make a deep copy of your object with angular.copy
once you pass it in, so e.g. myVal = angular.copy(myVal)
. After Angular 1.5, you can use <
in your bindings, which would then look like that:
bindings: {
myVal: "<"
}
However, note that if myVal is an object, you'll still have to do the deep copy using angular.copy
, the "<" only works for non-object values. See the following plunkr to see what I mean.