gpt4 book ai didi

javascript - Angular 模板未显示在主页上

转载 作者:行者123 更新时间:2023-11-28 18:44:37 25 4
gpt4 key购买 nike

我正在尝试在 Angular 应用程序的主 JavaScript 配置文件中制作小型页面模板。

语法似乎很合理,但每当我显示页面时,我只能看到预制的菜单栏,而没有其他内容。

fiddle :https://jsfiddle.net/Miega/mowwckze/9/

这是我的 JS 文件的配置部分:

.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('#/homePage', {
templateURL: 'homePage.html',
template: '<p>WELCOME HOME!</p>'
}).
when('#/pCredential', {
templateURL: 'pCredential.html',
template: '<p>INSERT CREDENTIALS INTO NODE.</p>'
}).
when('#/tLogin', {
templateURL: 'tLogin.html',
template: '<p>PLEASE LOGIN TO THE TECHNICIAN PAGE.</p><p>GET CREDENTIALS FROM OWNER.</p>'
}).
when('#/aLogin', {
templateURL: 'aLogin.html',
template: '<p>ADMINISTRATOR ACCESS.</p>'
})

//load default page on page refresh
.otherwise({
redirectTo: '#/homePage'
});
}])

非常感谢任何帮助。

最佳答案

不要同时使用 template 和 templateUrl,使用其中之一。不要使用#:

.when('/homePage', {
template: '<p>WELCOME HOME!</p>'
});

Fiddle

关于javascript - Angular 模板未显示在主页上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35583506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com