0

I'm writing an app with AngularJS 1.5.3

I have a parent component with some data in it that needs to be updated in the child component. Right now the data is not updating in the parent component even though the input boxes on the child look like they are updating.

Here is my fiddle: https://jsfiddle.net/aubz88/ab85L19c/

Here is some sample code:

var grandChildComponent = {
  bindings: {
    min: '<',
    max: '<'
  },
    template: `
    <div>
      Grand Child component
      <input ng-model="$ctrl.min" />
      <input ng-model="$ctrl.max" />
    </div>
  `
};
1
  • 1
    You should use two-way data bindings (=) in both of your child and grand child components. Commented Jun 8, 2018 at 16:17

1 Answer 1

3

That would be because you are using one-way bindings (Reference docs here and a helpful article here).

If you want your data updates to go from-parent-to-child and from-child-to-parent, then you need two-way data binding using the symbol =.

Here's a working JSFiddle

E.g.

var grandChildComponent = {
    bindings: {
        min: '=',
        max: '='
    },
    template: `
        <div>
            Grand Child component
            <input ng-model="$ctrl.min" />
            <input ng-model="$ctrl.max" />
        </div>
    `
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.