In den script.js definiert ist, den Sie verwenden 'template'
und schrieb '<home></home>'
, aber Sie haben zu Hause .html. und Sie möchten home.html als Vorlage verwenden. Sie templateUrl: 'home.html'
statt template:'<home></home>'
Auch für Ihren Code ändern template: <about></about>
& template: <contact></contact>
(function() {
'use strict';
angular.module('myVin', ['ui.router', 'homeModel'])
.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('home', {
url: '/',
template: '<home></home>'
})
.state('about', {
url: '/about',
template: '<about></about>'
})
.state('contact', {
url: '/contact',
template: '<contact></contact>'
});
});
})();
sehen im Snapshot verwenden sollten, gehen Sie bitte Änderung im roten Feld in Ihrem Code:
Verwenden Sie diesen Code im Skript.js und laufen wieder Ihren Code erfolgreich ausgeführt wird:
(function() {
'use strict';
angular.module('myVin', ['ui.router', 'homeModel'])
.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('home', {
url: '/',
templateUrl: 'home.html'
})
.state('about', {
url: '/about',
templateUrl: 'about.html'
})
.state('contact', {
url: '/contact',
templateUrl: 'contact.html'
});
});
})();
den Snapshot finden Sie nach dem Ändern des Codes:
@Arjun: Ihr Code ist auch richtig, fügen Sie einige html in deiner Schablone (wie ich getan habe, schrieb ich template: '<h1>Shubham Verma</h1>'
)
(function() { 'use strict';
angular.module('myVin', ['ui.router', 'homeModel'])
.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('home', {
url: '/',
template: '<h1>Shubham Verma</h1>'
})
.state('about', {
url: '/about',
templateUrl: 'about.html'
})
.state('contact', {
url: '/contact',
templateUrl: 'contact.html'
});
});
})();
Bitte beachten Sie die Snapshot:
bearbeiten Kommentar überprüfen Sie es bitte -> entfernen Backslash in Ihrem über Komponente – devadrion