Questions tagged [ng-html2js]

ng-html2js is a preprocessor for converting HTML files to AngularJS templates. It converts HTML files into JS strings and generates Angular modules. These modules, when loaded, put these HTML files into the $templateCache and therefore Angular won't try to fetch them from the server. For instance template.html will be served as template.html.js:

ng-html2js is a preprocessor for converting HTML files to AngularJS templates.

It converts HTML files into JS strings and generates Angular modules. These modules, when loaded, put these HTML files into the $templateCache and therefore Angular won't try to fetch them from the server.

For instance template.html will be served as template.html.js:

41 questions
39
votes
4 answers

Karma throws error: Can not load "ng-html2js", it is not registered

I'm getting an error when I run karma start: $ karma start INFO [karma]: Karma v0.10.2 server started at http://localhost:9876/ INFO [launcher]: Starting browser Chrome WARN [preprocess]: Can not load "ng-html2js", it is not registered! Perhaps…
Ph0en1x
  • 9,943
  • 8
  • 48
  • 97
10
votes
1 answer

configuring karma ng-html2js preprocessor to find my templates in inside a directory

The problem I am having is that I want to make the templateUrl: "partials/my-directive.html" but currently I have to make it templateUrl: "app/partials/my-directive.html in order for it to be loaded by Karma. this is my folder structure (basically…
Subtubes
  • 15,851
  • 22
  • 70
  • 105
6
votes
1 answer

setting up ng-htmljs-preprocessor karma preprocessor

I am setting up my Karma configuration file, but I do not fully understand some of options that exist as I am not having success testing templates that have ran through the ngHtml2JsPreprocessor and have been $templateCached Inside of the…
Winnemucca
  • 3,309
  • 11
  • 37
  • 66
6
votes
2 answers

karma-ng-html2js-preprocessor not working gulp + angular + karma + ng-html2js

I can't make karma-ng-html2js-preprocessor working for external template. Package Json file: ..... "gulp-karma": "*", "karma-coverage": "*", "karma-jasmine": "*", "karma-ng-html2js-preprocessor": "*", …
rak
  • 61
  • 1
  • 4
5
votes
1 answer

Cant seem to get 'karma-ng-html2js-preprocessor'doing its work

Keeps on giving me this error: Module 'templates' is not available! You either misspelled the module name or forgot to load it. I implementend unit testing of Directives in several Angular projects and now it just wont seem to work. Here is my…
San Jay Falcon
  • 993
  • 1
  • 9
  • 20
5
votes
1 answer

Directive with templateUrl - testing with ng-html2js

I created a directive with inline template, tested it, everything worked fine. Now I have put the template into separated .html file and reference it via templateUrl from directive. Directive works on my page, but the tests are broken saying: …
przno
  • 3,476
  • 4
  • 31
  • 45
4
votes
2 answers

AngularJS Karma Test: Unexpected request: GET.template.html

I'm trying to set up karma tests for my AngularJS app but I am somehow failing constantly. I have followed all the steps here but I have the feeling the ng-html2js preprocessor is not working properly. I am always getting the following…
user3083022
  • 415
  • 2
  • 5
  • 20
4
votes
2 answers

isolateScope() gives undefined - Unit Testing directives with Karma

As stated in the title of the question, I am getting undefined when calling isolateScope(). I tried to Unit Test my Angular Directive based on the instructions given on Unit Testing AngularJS Directives With External Templates. Here is my…
Jagrut
  • 922
  • 7
  • 21
4
votes
0 answers

karma-ng-html2js-preprocessor not setting the path properly

I'm testing my statement directive. It has a templateUrl of: /directives/Statement/statement.directive.html My app's file structure: - tango - client - directives - Statement - statement.directive.html - server - test I'm…
Adam Zerner
  • 17,797
  • 15
  • 90
  • 156
3
votes
1 answer

ngHtml2JsPreprocessor does not load the module containing the templates, tested with karma

Testing my angular app with karma ngHtml2JsPreprocessor, I have read dozens of pages on how ton configure karma to generate js templates instead of html ones that are loaded by Angular Directives, I am stuck with the message : Module 'js_templates'…
Bil5
  • 502
  • 1
  • 5
  • 15
3
votes
2 answers

Karma 0.12.9, unit tests, karma-ng-html2js-preprocessor

No idea what the problem is... karma.conf.js files: [ // TEMPLATES 'app/scripts/directives/views/profile_picture.html', preprocessors : { // generate js files from html templates …
Lukas Lukac
  • 7,766
  • 10
  • 65
  • 75
2
votes
1 answer

How to test a directive with a scroll event?

I'm trying to test a directive that allows me to do infinite scroll in my app. The directive works fine in my production code. This question is really close to How to test AngularJS Directive with scrolling and if someone says they are identical…
2
votes
1 answer

Test angular directive with templateUrl

I am trying to test my Angular directive with Karma+Jasmine. So as my directive has templateUrl I need caching the template with karma-ng-html2js-preprocessor. My karma.conf.js file: ... files: [ ... 'static/views/**/*.html', // to match my…
2
votes
1 answer

Karma preprocessor not running

My karma.conf.js includes: plugins: [ 'karma-jasmine', 'karma-phantomjs-launcher', 'karma-ng-html2js-preprocessor' ], preprocessors: { '../../mypath/*.html': ['ng-html2js'] }, ngHtml2JsPreprocessor: { moduleName:…
TrueWill
  • 25,132
  • 10
  • 101
  • 150
2
votes
0 answers

how to use url parameters with karma-ng-html2js-preprocessor

Im trying to test out my directives, but when i load everything in with karma, and i use ng-html2js. It loads the modules fine, and then it fails on Error: Unexpected request: GET modules/contenteditable/contenteditable.html?v=1 No more request…
Simon Dragsbæk
  • 2,367
  • 3
  • 30
  • 53
1
2 3