If I have an array of objects, and loop through them assigning a value to an attribute for each one, WebStorm warns me:
Values assigned to primitive w
I faced similar issue with angular custom directive.
below was my custom directive:
function customDirective() {
return {
scope: {
model: '='
}
link: function(scope) {
scope.resetModel = function() {
scope.model.name = null; //In these lines I was getting the above
scope.model.email = null; //mentioned warning in webstorm.
}
}
}
}
After going through the $compile docs, I decided to use the below code which solves this warning and works fine with the binding to child and parent scopes, yes of course unless until your model is an object reference.
function customDirective() {
return {
scope: {
model:'<' // Please refer the above linked angular docs for in detail explanation.
}
link: function(scope) {
scope.resetModel = function() {
scope.model.name = null;
scope.model.email = null;
}
}
}
}