我多年来一直在看我的应用程序,试图找到错误但却无法在我的生活中找到它。
这是我的HTML
<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Ericsson KAS</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bower_components/html5-boilerplate/css/normalize.css">
<link rel="stylesheet" href="bower_components/html5-boilerplate/css/main.css">
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<link rel="stylesheet" href="css/eBootstrap.css"/>
<link rel="stylesheet" href="css/app.css"/>
<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
</head>
<body>
<div id="menu-container">
<div id="menu-top" class="e-full-blend"></div>
<div id="menu-bottom" class="gray-gradient">
<img ng-src="images/econ.png" height="35" width="27" class="logo" />
<center><h2 class="ericsson-capital-dark">Knowledge Assessment Solution<h2></center>
</div>
</div>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div id="main" class="col-xs-10 col-xs-offset-1" ng-view>
</div>
<div id="version-legend">Version: <span app-version></span></div>
<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="js/jquery-2.1.1.min.js"></script>
<script src="app.js"></script>
<script src="js/controllers.js"></script>
<script src="partials/view1/view1.js"></script>
<script src="partials/view2/view2.js"></script>
<script src="partials/view3/view3.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script>
</body>
</html>
app.js
'use strict';
// Declare app level module which depends on views, and components
angular.module('myApp', [
'ngRoute',
'controllers',
'view1',
'view2',
'view3',
'myApp.version'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({redirectTo: 'partials/view1'});
}]);
第一个视图/部分由于某种原因没有加载到ng-view
view1.js
'use strict';
angular.module('view1', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/view1', {
templateUrl: 'partials/view1/view1.html',
controller: 'View1Ctrl'
});
}])
.controller('View1Ctrl', [function() {
}]);
view1.html
<div id="first-view" class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3 col-lg-4 col-lg-offset-4" ng-controller="View1Ctrl as firstController">
<form role="form" class="form-horizontal">
<div class="form-group">
<label for="name" class="col-xs-3 control-label">Name</label>
<div class="col-xs-9">
<input type="text" class="form-control">
</div>
</div>
<div class="form-group">
<label for="domain" class="col-xs-3 control-label">Domain</label>
<div class="col-xs-9">
<input type="text" class="form-control">
</div>
</div>
<div class="form-group">
<label for="jobRole" class="col-xs-3 control-label">Job Role</label>
<div class="col-xs-9">
<input list="browsers" class="form-control">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
</div>
</div>
<div class="form-group" ng-controller="ButtonCtrl as bCntrl">
<div>
<a class="clean-link-light lower-right" href="#/view2"><button type="submit" class="e-btn e-btn-success" >{{ bCntrl.nextButtonTitle }}</button></a>
<button id="admin-button" type="submit" class="e-btn e-btn-default">{{ bCntrl.adminButtonTitle }}</button>
</div>
</div>
</form>
</div>
我不知道我设法做了什么来阻止它工作但它工作正常,直到我复制了一个partials文件夹来添加一个view4。这搞砸了所有事情,即使我已经删除了视图4它仍然没有运行。
任何帮助都不仅仅是一种帮助!
谢谢!
答案 0 :(得分:0)
我不是100%肯定,但在app.js
$routeProvider.otherwise({redirectTo: 'partials/view1'});
并在view.js
中 $routeProvider.when('/view1', {...}
试试view.js:
$routeProvider.when('partials/view1', {...}
答案 1 :(得分:0)
您可以定义所有进入app.js的道路 示例:
app.config(['$routeProvider',function($routeProvider) {
$routeProvider.when('/login',
{
templateUrl: 'views/login.html',
controller: 'loginCtrl'
});
$routeProvider.when('/home/',
{
templateUrl: 'views/main.html',
controller: 'homeCtrl'
});
和默认道路
$routeProvider.otherwise({redirectTo: '/login'});