Skip to content

Instantly share code, notes, and snippets.

@langhard
Last active December 21, 2015 08:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save langhard/6277825 to your computer and use it in GitHub Desktop.
Save langhard/6277825 to your computer and use it in GitHub Desktop.
AngularJS (1.1.5) - Directives - Dynamic Template URL
'use strict';
angular.module('clientApp')
.directive('formFields', function () {
return {
templateUrl: function (tElement, tAttrs) {
return tAttrs.templateUrl;
},
restrict: 'E'
};
});
<ng-form name="new-info" ng-init="newInfo">
<form-fields template-url="views/partials/model/info/form.html"></form-fields>
<input type="submit" ng-click="apiPost(info)"/>
</ng-form>
@hackdan
Copy link

hackdan commented Dec 19, 2013

Thanks Thanks Thank Thanks!!!!

@angi-
Copy link

angi- commented Jan 19, 2014

Just what I was looking for, many thanks!

@HugoCapocci
Copy link

I just don't undestand...

  • your templateUrl is not dynamic, it's hardcoded in your html template.
  • don't you are re-coding ng-include in fact ?

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