tilwinjoy / angular-bootstrap-material

AngularJS directives for bootstrap material design components
http://tilwinjoy.github.io/angular-bootstrap-material
21 stars 13 forks source link

directive scope is not updating parent model #7

Closed yesid-bocanegra closed 8 years ago

yesid-bocanegra commented 8 years ago

im trying to use BMD to build a set of directives to apply various filters and validations, to different kind of inputs and to make things simplier making every input as close to a one liner as possible.

so i make my own directives and define in templetes the markup using bmd-* attributes, and it seems to work fine. i set the model in the directive using

scope:{ modelValue: '=' }

and then assign as ng-model="modelValue" for the inputs in the template.

the thing is, if i update the model straight from the controller it updates just fine the inputs, and it does the validations that where setup. but if i write on the input there are no events firing at all then doesnt change in the directive nor in the parent model, i checked with ng-inspector and the model doesnt change when the input is writen into. i did the same thing with plain html and it works just fine, but once i add the bmd-* attirbutes its doesnt work anymore, any clue on this issue?

tilwinjoy commented 8 years ago

Judging by

scope:{
  modelValue: '='
}

and ng-model="modelValue" I believe you're facing the common AngularJS issue of two way binding to primitive value. See this Stack Overflow answer or this answer. In short your binding should be in the form of ng-model="twoWayBoundObject.somePrimitiveModelValue".

If that doesn't help please create a minimal demo as mentioned in contribution guidelines so that I can get a better understanding of the issue...

yesid-bocanegra commented 8 years ago

i have read the links you shared and i think i understand the root of the problem, it seems to be because there is some kind of sharing issue with transcluded directives when dealing with the scope. i dont know if i will to have time to share a demo of the issue. but i will have this in mind and open another issue if i cant find the answer later on