Search code examples
javascriptangularjsdirectiveangularjs-ng-include

Angular Directive with ng-include template


I've defined the following directive I've defined the following dirctive in my js file:

.directive('tabContent',function(){    
                return {
                restrict: 'E',
                template:'<div ng-if="view==\'card" ng-include="card.html"></div>'
            }
        })

and than used it in my html:<tabContent></tabContent> but all I got is a remark <!--div--><!--ng-if--><!--ng-include--> What am I missing?


Solution

  • You are missing a closing escaped ' on card in your string and ng-include requires single quotes as well, since it will parse your url as an expression.

    template:'<div ng-if="view==\'card\'" ng-include="\'card.html\'"></div>'