mardi 30 juin 2015

AngularJs testing. Where to put template

I am currently testing an angularjs directive. This directive has a templateUrl. I would lke to test the view to make sure it was initialized correctly i.e. correct number of buttons, certain elements hidden.

The problem I am having is that when I insert my html file into the template cache I still get :

"message": "Unexpected request: GET partials/stuff/stuff-leader.html

I assumed that when I used the templateCache I would no longer have to use:

 $httpBackend.whenGET("partials/stuff/stuff-leader.html").respond([{
        userId: 000
    }]);

but this does not seem to be the case. I am wondering am I correctly inserting the template, here is how I am doing it:

 template = $templateCache.get('/full/root/disk/path/to/file/stuff/stuff-leader.html');
    $templateCache.put('/myApp/templates/stuff-leader.html',template);

Is this correct, or should I be placing it somewhere else?

Aucun commentaire:

Enregistrer un commentaire