Skip to content

Instantly share code, notes, and snippets.

@mllrjb
Last active December 23, 2015 11:19
Show Gist options
  • Save mllrjb/6627721 to your computer and use it in GitHub Desktop.
Save mllrjb/6627721 to your computer and use it in GitHub Desktop.
Angular directive to support expressions in `input.name`, pending merge of https://github.com/angular/angular.js/pull/3135.
.directive('ngName', function() {
return {
restrict: 'A',
require: ['^form', 'ngModel'],
link: function($scope, ele, attr, ctrl) {
var formCtrl = ctrl[0];
var ngModel = ctrl[1];
var name = $scope.$eval(attr.mppName);
if (ngModel.$name != name) {
formCtrl.$removeControl(ngModel);
ngModel.$name = name;
attr.$set('name', name);
formCtrl.$addControl(ngModel);
}
}
}
})
@mllrjb
Copy link
Author

mllrjb commented Sep 19, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment