There are many examples using directives for creating dynamic forms with angularjs but i'm trying to do something different.
Currently i am using this in my js file:
.directive('myCustomer', function() {
return {
restrict: 'E',
templateUrl: 'my-customer.html'
};
});
This is my-customer.html
Name: {{customer.name}} Address: {{customer.address}}
How to request a templateUrl from web like this:
.directive('myCustomer', function() {
return {
restrict: 'E',
templateUrl: 'http://www.garsoncepte.com/my-customer.php'
};
});
Working example can be seen here:
If you'd checked the error in the console it shows up as an untrusted URL because it's not on the same domain.
You can use $sce
to allow the domain.
.directive('myCustomer', ['$sce', function($sce) {
return {
restrict: 'E',
templateUrl: $sce.trustAsResourceUrl('http://www.garsoncepte.com/my-customer.php')
};
}]);