角度UI路由器无法在chrome应用程序上运行
Angular UI router not working on chrome app
我正在使用带有angular-ui-router
angularjs
创建一个 chrome 应用程序。
应用.js
var foo = angular.module('foo', [
'ui.router',
])
.config(['$stateProvider', '$locationProvider',
function($stateProvider, $locationProvider) {
console.log("This works fine.");
$stateProvider
.state('login', {
url: '/',
templateUrl: 'modules/login/templates/login.html',
controller: 'loginController'
})
}])
登录.js
foo.controller('loginController',
['$scope',
function($scope){
console.log("This should be printed on the console.");
}])
窗口.html
<!DOCTYPE html>
<html ng-app="mycurechrome">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="components/chromestrap/js/jquery-2.0.3.min.js"></script>
<script src="components/chromestrap/js/bootstrap.min.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.min.js"></script>
<script src="app.js"></script>
<script src="modules/login/controllers/login.js"></script>
<link href="components/chromestrap/css/bootstrap.min.css" rel="stylesheet">
<link href="css/window.css" rel="stylesheet">
</head>
<body>
<div ui-view></div>
</body>
</html>
manifest.json
{
"name": "foo",
"description": "bar",
"version": "0.1",
"manifest_version": 2,
"app": {
"background": {
"scripts": [
"background.js"
]
}
},
"icons": { "16": "icon-16.png", "128": "icon-128.png" }
}
背景.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('window.html', {
'outerBounds': {
'width': 1000,
'height': 600
}
});
});
在app.js
执行console.log("This works fine.");
,但login.js
上的 log() 不会。
我不认为我使用ui-router
错,但我持怀疑态度,因为谷歌浏览器应用程序可能有不同的方法。
尝试导航到登录状态,如果这是您的默认状态,请尝试:
.config(['$stateProvider', '$locationProvider', '$urlRouterProvider',
function($stateProvider, $locationProvider, $urlRouterProvider) {
console.log("This works fine.");
$urlRouterProvider.otherwise('/login');
$stateProvider
.state('login', {
url: '/login',
templateUrl: 'modules/login/templates/login.html',
controller: 'loginController'
});
}]);
相关文章:
- Canvas Html5绘图应用程序,移动画布会导致重大问题
- Emberjs应用程序加载在除Index之外的所有路由上
- 使用电话间隙在Android应用程序中显示SQL Lite的数据
- 在AngularJS应用程序中使用封装指令和路由的推荐方式是什么
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- angular 1.5应用程序中的导航栏
- 在Web应用程序中使用Highcharts javascript
- angularjs+rails应用程序中未显示模板
- 使用acess代币登录Facebook,并通过网络应用程序离线发布
- 从HTTPGET返回一个自定义对象列表,以便在Angular 2应用程序中使用
- 科尔多瓦页面类应用程序中的多个谷歌地图
- 使用谷歌应用程序脚本将服务器端数据表返回到客户端
- Angularjs-utils高亮过滤器在搜索时破坏应用程序
- 在phonegap应用程序内部重定向不起作用
- 使用谷歌应用程序脚本从工作表中获取值并将其显示在文本框中
- MockJax没有在JavaScript应用程序中发送对我AJAX请求的响应
- Node.js正在更改应用程序以使用集群模块
- 如何加载/构建 Chrome 应用/扩展程序并以编程方式运行
- Chrome 应用/扩展程序 - 后台请求错误,或允许应用问题加载 Google 文档 API
- 检测我使用的是 chrome 应用/扩展程序