angularjs - Access parent data model in directive -


i wrote directive check double values in data column:

the markup

<table>    <tr data-ng-repeat-start="rowitem in vm.model.data" ...>       <td>          <input type="text" data-ng-model="rowitem.id" data-unique-column="vm.model.data" />       </td>       ...    </tr> </table> 

and directive

(function () {     'use strict';      angular.module('app').directive('uniquecolumn', function () {         return {             restrict: 'a',             require: 'ngmodel',             link: function (scope, element, attrs, ngmodel) {                 element.on('keyup blur', function () {                      scope.$eval(attrs.uniquecolumn).foreach(function (item) {                         // validation logic                     });                 });             }         };     }); })(); 

everything works fine asked myself if there solution access data of repeater, i.e. vm.model.data, without passing argument directive?

because didn't isolate scope, can read javascript's prototypal inheritance. can perhaps access method child lookup parent's. , perhaps use $index parameter.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -