Skip to content

Instantly share code, notes, and snippets.

@kalisjoshua
Created January 26, 2014 03:15
Show Gist options
  • Save kalisjoshua/8627855 to your computer and use it in GitHub Desktop.
Save kalisjoshua/8627855 to your computer and use it in GitHub Desktop.
AngularJS linking form constructor with dynamic field name
angular.module('app')
.directive('dynamicFields', function () {
return {
link: function ($scope) {
// this hack brought to you by kalisjoshua; plenty of searching
// and one big guess that this might work, only time will tell
$scope.validation[$scope.name] = $scope.validation['{{name}}'];
},
scope: {
name: '@',
validation: '='
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment