Context Manu AngularJS Directive
http://angularjs.org/
by Yaprak Ayazoğlu
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.16/angular.min.js"></script>
<div ng-controller="MainCtrl">
<div>
Field1:
<input ng-model="myItem.field1"></input>
</div>
<div>
Field2:
<select ng-model="myItem.field2" ng-init="myItem.field2=fieldOptions[0]" ng-options="val for myItem.field2 in fieldOptions" ng-change="changed(myItem)"></select>
<div> AnotherField:
<select ng-model="otherFieldName" ng-init="otherFieldName=fieldOptions[0]" ng-options="otherFieldName for otherFieldName in fieldOptions" ng-change="changed(myItem)"></select>
</div>
</div>
</div>
JavaScript
var myApp = angular.module("myApp",[]);
myApp.controller( "MainCtrl", [ "$scope", function($scope) {
console.log("Main Controller loaded.");
$scope.fieldOptions = [ 'opt1', 'opt2', 'opt3' ];
$scope.changed = function( myItem ){
console.log("Field2 changed.");
console.log(myItem);
};
}]);