Angularjs templateUrl fails to bind attributes inside ng-repeat

后端 未结 5 1204
时光取名叫无心
时光取名叫无心 2020-12-20 01:59

I\'m using directive to display html snippets.

And templateUrl inside the directive, to be able to include snippets as html file.

The directive does not wor

5条回答
  •  情深已故
    2020-12-20 02:41

    it seems you are trying to have different views based on some logic and you used templateUrl function but Angular interpolation was not working, to fix this issue

    don't use templateUrl

    so how to do it without using templateUrl

    simply like this

    app.directive("myTemplate", function() {
        return {
            link: function(scope, elem, attrs) {
               $scope.templateUrl = '/ActivityStream/activity-' + $scope.ativity.type + '.html'
            },
            template: "
    " }; });

    hope this is simple and esay to understand

提交回复
热议问题