I'm following the conventions made by John Papa, but unfortunately I'm not really figuring out how to bind values from children controllers to parent controllers, using ui-router, ControllerAs and vm variables instead of $scope.
I made two examples, first example illustrates the working environment, so without ControllerAs and the normal $scope variable, this works, but when I change $scope to
var vm = this;
it doesn't process any changes made to children controllers to the parent. I really want to make it work without working with some kind of PUBSUB pattern, because this is one of the most important features of working with two-way-data binding, but I don't know if this is possible within this situation?
I've created two Plunker examples to illustrate the problem:
Plunker example 1:
- Controller + $scope
- http://embed.plnkr.co/oNsCF2YnfKP3wzGNhFUi/preview
Plunker Example 2:
- With vm variable and ControllerAs syntax
- http://embed.plnkr.co/s68o08dtBafHKflD8ZLZ/preview
The first Example works, when changing some input fields within the template 'register-identification.html', this will directly change {{formData}} from the parent controller (RegisterBaseController).
The second Example doesn't process any changes.
I hope my explanation makes any sense? Hopefully someone can help me out!
Many thanks in advance!
Ken