Closed lambert-velir closed 8 years ago
@lambert-velir try requiring your template.
// index.js
require('bar/bar.html');
app.config(function($routeProvider){
$routeProvider
.when("/bar", {
templateUrl: "bar/bar.html",
controller: require("./bar/barCtrl.js")
});
});
Cool, require("./bar/bar.html");
works, thanks!
@javoire, you might want to consider adding this to the documentation. This wasn't apparent to me.
Hmm yeah. I'm thinking though that the very concept behind browserify is to require()
the files you need in your final js output, i.e. all the files that will be sent and processed through browserfys pipeline. So if a html needs to be processed by browserify and compiled to an angular template it needs to be required :) But maybe it won't hurt to show that in an example. I'll give it some thoughts. Cheers
@javoire it would be nice if we did not need to require the templates!
True. But that's how browserify works! You require all the source files you want to be a part of your bundle. How would browserify know where your templates are if you don't require them? ^^
It would be quite interesting if a node script could look for templateUrl: "path/to/template.html" and inject a require tag before running browserify.
Hopefully it wouldn't be too costly to run.
Yeah I guess that could make sense ^^
Hey guys, maybe I'm doing something but I'm using the require and it is working. However, my karma testing are failing with SyntaxError: Unexpected token (1:0) while parsing file:...
I already installed karma-ng-html2js-preprocessor and followed its documentation. The issue is that Karma is getting that require('file.html') and failing. Any hints?
Hmm, well karma would have to use browserify somehow also, is it?
What you can do otherwise, is to bundle (browserify) the code before running karma, so that karma will take the finished bundle.js
(or whatever you've named you output file) as it's input in karma.conf.json
Hi Jonatan, to bundle the file previous to running Karma is not an option due to how the application and the tests have been set up in the past. We are using browserify as a preprocessor in Karma. I'm currently investigation how can I add ng-html2js as a transform in browserify options in Karma
browserify: {
debug: true,
transform: [ 'ng-html2j' ]
}
i agree that it would be better if the documentation said that you need to require the templates in your code. I only started using browserify today so it wasn't at all obvious to me. Great plugin though!
agreed :) re-opening
Please, man! Add this to the documentation - I spent 2 hours until got this.
closed in #37
Hi-
I'm trying to pipe my index.js file though this transform to add my templates to the $templateCache. Is this transform supposed to parse out any templateUrl declarations? In my index.js, I have:
My gulp task looks like this:
Is this transform supposed to recognize bar/bar.html and add it to my bundle?