angular-templates
Compiles angular templates into the template cache.
Installing
In order to use this compiler, you need first to remove the default HTML compiler in Meteor, by running:
$ meteor remove blaze-html-templates
And then add the compiler for Angular 1.0 by running:
$ meteor add angular-templates
How to use the compiler?
So you do not have to do anything else besides adding the compiler to your project. The compiler will automatically compiles every .html
file you add to your project.
Manually
1angular.module('app') 2.component('app', { 3 templateUrl: '/ui/component/app.html' 4 // ... rest of options 5 });
Using url of a template
1import templateUrl from './ui/component/app.html'; 2 3angular.module('app') 4 .component('app', { 5 templateUrl, // equivalent to `templateUrl: templateUrl` 6 // ... rest of options 7 });
Using template as a string
1import template from '../ui/component/app.html!raw'; 2 3angular.module('app') 4 .component('app', { 5 template, // equivalent to `template: template` 6 // ... rest of options 7 });
Our recommendations
Since a component doesn't exist without its template, in our opinion it is the best approach to import the content.
This is why we created urigo:static-templates
.
We recommend you to use the template as a string
method, this way you can easily migrate to urigo:static-templates
.
Migration process:
- Partly move all of your components to work with
template
(!raw
suffix) instead oftemplateUrl
. - Remove
angular-templates
. - Add
urigo:static-templates
. - Remove
!raw
suffix from template imports. It could be done component by component since!raw
suffix also exists inurigo:static-templates
. We've done this to make the migration process easier.
Known issues
- TypeScript warnings about missing modules [Urigo/angular-meteor#1402]