2017-10-18 6 views
1

Il ne fonctionne pas avec le templateURL spécifié: test.html mais fonctionne si vous spécifiez le modèle: 'Bonjour'angularjs ng-route. fonctionne pas templateURL

TRAVAIL

app.config(function($routeProvider){ 
    $routeProvider 
    .when('/test', { 
     template: '<h1>home</h1>', 
     controller: 'ctrl' 
    }) 

    // .otherwise({ 
    // redirectTo: '/home', 
    // controller: 'ProductCtrl' 
    // }); 
}); 

NE TRAVAILLEZ

app.config(function($routeProvider){ 
    $routeProvider 
    .when('/test', { 
     templateUrl: 'test.html', 
     controller: 'ctrl' 
    }) 

    // .otherwise({ 
    // redirectTo: '/home', 
    // controller: 'ProductCtrl' 
    // }); 
}); 

et j'ai un signe ! dans le chemin d'accès au fichier qui est #!/test

LINK

<a style="color:white;" href="#!/test">Go</a> 

J'utilise nw.js

+1

montrent la structure de votre dossier dans lequel vous mettez votre fichier test.html – jitender

+0

Refer this https://stackoverflow.com/questions/40635098/angularjs-routing-with-templateurl –

Répondre

1

Vous pouvez essayer de mettre un chemin vers l'url de votre modèle

.when('/test', { 
    templateUrl: './test.html', 
    controller: 'ctrl' 
    })