javascript - include html templates in a bower component for angular -
javascript - include html templates in a bower component for angular -
i'm making reusable directives angular apps putting them in separate bower component.
i utilize templateurl directives not forced 1 of 3 options in post: how utilize separate templates angular directive bower package? here amoderate paraphrasing of suggestions: 1 re-create , past html in js file, 2 using grunt compile templates js, or 3 set templates in different directory , have server handle requests, directives not usable bower installation only.
is there improve way utilize template files directives in component, or bower not set work in manner?
i did resolve issue. i'm sorry not posting reply earlier.
i ended using grunt-angular-templates
if using gulp, there comparable library.
this directory structure, html in templates directory
project src controllers directives templates
and how configured options in gruntfile
grunt.initconfig({ ... ngtemplates: { projectname: { cwd: 'src', src: 'templates/**/*.html', dest: 'src/templates/templates.js' } }
i have grunt task grunt-contrib-concat concat javascript files within project. so, templates bundled final js file.
in code , tests, able reference html files same way regardless of if loading html or javascript version.
ex:
angular.module('mymodule') .directive('mymoduledirective', function () { homecoming { restrict: 'e', templateurl: 'templates/maintemplate.html' }; });
javascript angularjs angularjs-directive bower
Comments
Post a Comment