I want to use a http url as templateUrl in my angularjs directive like below:

angular.directive('mydir', function() {
       return {
        restrict: 'E',
        link: function(scope, element, attrs) {
           ....
        },
        templateUrl: "example.com/def.html"
    }
});

But after changing it to the above url template is not getting visible on the page. Is there any workaround for this.

share|improve this question
    
because it changing only field you put directive . pls post your html code – Thanh Tùng 31 mins ago
    
Two things; you don't actually include the HTTP scheme in the URL (i.e., it should be templateUrl: "http://example.com/def.html"). Secondly, this would require you to have permission to request that URL via ajax (using CORS). If you look at your network tab of your browser tools, you're likely getting an error. – Mike McCaughan 27 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.