jasin_89
jasin_89

Reputation: 2001

angular routing without webserver to load templates

Is it possibile in angular to load templates without web server, I found one example here: https://groups.google.com/forum/#!topic/angular/LXzaAWqWEus but for me it is only printing templates paths not content for them.

Is there any working example for this?

Upvotes: 2

Views: 930

Answers (1)

marko
marko

Reputation: 2831

I'm ignoring the "no web server" part of the question. Here's an example on how you can put a template directly in a script tag and use it with a directive.

<body ng-app="myApp">
<script type="text/ng-template" id="templateTemplate.html">
     <div>
     I am the <span ng-transclude>{{templateAdjective}}</span> 
     template result.
     </div>
</script>

<div>
    <test>best</test>
    <test>optimal</test>
</div>

<script>
    var app = angular.module('myApp',[]);

    app.directive('test', function() {
        return {
            restrict: 'E',
            templateUrl: 'templateTemplate.html',    
            transclude: true,
            replace: true
        };
    });
</script>
</body>

template in script tag jsfiddle

Upvotes: 1

Related Questions