Angular应用程序未启动
Angular app not being bootstrapped?
我正试图弄清楚我的angular应用程序不工作的原因。
所以我有以下代码:
app.modules.js
angular.module("quickscan", [
"ui.router",
"quickscan.controllers"
]);
angular.module("quickscan.controllers", []);
app.routes.js
var app = angular.module("quickscan");
app.config(function ($stateProvider, $urlRouterProvider, $controllerProvider, $compileProvider, $filterProvider, $provide, $httpProvider) {
$urlRouterProvider.otherwise("/test");
$stateProvider
.state("app", {
abstract: true,
templateUrl: "shared/Layout/Main.html"
})
.state("app.root", {
url: "/test",
templateUrl: "shared/Main/Main.html"
})
.state("buildings", {
url: "/buildings",
controller: "BuildingDetailController",
templateUrl: "components/BuildingDetail/BuildingDetailView.html"
});
});
index.html
<!DOCTYPE html>
<html>
<head>
<title>Quickscan App v2</title>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=no">
<link rel="stylesheet" href="content/css/app.css">
</head>
<body>
<div ng-view id="view"></div>
<!-- order dependend scripts -->
<script src="scripts/jquery/jquery.js"></script>
<script src="scripts/angular/angular.js"></script>
<script src="app/app.module.js"></script>
<!--remaining scripts-->
<script src="content/js/scripts.js"></script>
<!--angular scripts-->
<script src="content/js/all.js"></script>
<script>
setTimeout(function() {
angular.bootstrap(document, ['quickscan']);
console.log("Hello");
}, 3000);
</script>
</body>
</html>
all.js
(function () {
var app = angular.module("quickscan");
app.config(function ($stateProvider, $urlRouterProvider, $controllerProvider, $compileProvider, $filterProvider, $provide, $httpProvider) {
$urlRouterProvider.otherwise("/test");
$stateProvider
.state("app", {
abstract: true,
templateUrl: "shared/Layout/Main.html"
})
.state("app.root", {
url: "/test",
templateUrl: "shared/Main/Main.html"
})
.state("buildings", {
url: "/buildings",
controller: "BuildingDetailController",
templateUrl: "components/BuildingDetail/BuildingDetailView.html"
});
});
})();
var Building = function (data) {
// some other class
return building;
};
var Category = function (data, parent, building) {
// some class
return category;
};
(function () {
"use strict";
angular
.module("quickscan.controllers")
.controller("BuildingDetailController",
function ($scope, $rootScope) {
var vm = this;
vm.title = "Building Detail";
function activate() {
console.log("test");
}
activate();
});
})();
(function () {
"use strict";
angular
.module("quickscan.controllers")
.controller("CategoryDetailController",
function ($scope, $rootScope) {
var vm = this;
vm.title = "Building Detail";
function activate() {
console.log("test");
}
activate();
});
})();
但该应用程序没有加载我的任何视图,我的控制器没有报告test
,也没有重定向到/#
,也没有显示任何错误,有人知道吗?
看起来您没有使用ui view指令,请参阅https://github.com/angular-ui/ui-router/wiki/The-Components
您的
<div ng-view id="view"></div>
应该是
<div ui-view></div>
相关文章:
- 从浏览器启动应用程序
- 使用重定向来启动应用程序,并且仍然停留在asp.net中的同一页面中
- 按钮启动应用程序,但不会启动两次
- 如何在启动应用程序之前强制网络驱动程序安装应用程序
- 重新启动时自动启动应用程序
- Jquery Mobile,如何重新启动应用程序
- GWT.延迟启动应用程序
- 使用二维码启动应用程序或重定向到网页
- 从webview启动应用程序,如果未安装,则重定向到播放商店
- iOS 9.3.2自定义URL方案不能从Safari启动应用程序
- Mobilefirst Ionic ng启动应用程序点击两次
- 需要重新启动应用程序来查看javascript更改
- 在windows中从网页启动应用程序
- 电子-错误启动应用程序
- 用于node.js的jxcore包是否在浏览器中启动应用程序?
- 如何使用javascript启动应用程序
- 在Windows 8 WinJS应用程序中启动应用程序是否有唯一的会话ID
- 是否可以使用 HTML/Javascript 按名称启动应用程序
- 使用 JScript 启动应用程序
- Angular Ionic UI-Router - 如何确保在嵌套状态下启动应用程序时加载所有父视图