Search This Blog


Angular JS Tutorial2: ng-init,ng-repeat,sharedscope

The ng-init directive initializes application data.

The ngRepeat directive instantiates a template once per item from a collection.

In order to share data between scopes by model, use the model property like samplemode.sampledata

Example :

<!DOCTYPE html>
<html lang="en" ng-app="">
 <script src=""></script>

 <div ng-init="menu='chicken';
  <input type="text" ng-model="menu"/>
Share the data between this textbox and textboxes inside the country:city loop use the property like 'message.sharescope'<br/>
Otherwise it will be unidirectional binding from outer ti inner loop, when you use only 'message'<br/>
<input type="text" ng-model="message.sharescope"/><!--to share data between scope, use the property like 'message.sharescope' inplace of 'message', else innser scope value will not be passed to outer scope-->
<p ng-repeat="place in places">
 {{}} :{{}}
 <input type="text" ng-model="message.sharescope">


No comments: