dmitryprogrammer
dmitryprogrammer

Reputation: 376

AngularJS: Ng:init - how to assign ng:model?

I have ng:repeat, created by json (methods), inside it creates a series of radio buttons that are characterized by iteration (method).

Below, I need to create a variable that will be based on method selected radio button, for use in the future. I will prepare the template for clarity.

<li ng:repeat="method in methods">
  <label>
    <input type="radio" ng:model="$parent.deliveryMethod" ng:value="method" />
  </label>
</li>

<table ng:init="myValue = deliveryMethod.price | format">
  <tr>
    <td ng:bind="myValue"></td>
  </tr>
</table>

I hope the point is clear. The problem is, as I understand it, ng:init is triggered earlier than time to form methods.

What I must to do?

Thanks!

Upvotes: 0

Views: 167

Answers (1)

KpTheConstructor
KpTheConstructor

Reputation: 3291

You're syntax looks incorrect , You should be declaring ng- as listed below :

ng-repeat
ng-model
ng-init
ng-bind

ect...

docs here: https://docs.angularjs.org/api/ng/directive/ngRepeat

upadte - to apply method to radio button try ng-change :

ng-change="dosomething()"

Upvotes: 1

Related Questions