多年来,我一直在寻找我的应用程序,试图找出问题所在,但似乎无法找到我的生活。

这是我的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之前,它工作正常。这搞砸了一切,甚至我删除了view4仍然无法运行。

任何帮助都不胜枚举!

谢谢!

最佳答案

我不确定100%,但是在app.js中

$routeProvider.otherwise({redirectTo: 'partials/view1'});

和在view.js中

$routeProvider.when('/view1', {...}

在view.js中尝试:

$routeProvider.when('partials/view1', {...}

关于javascript - AngularJS没有将HTML加载到ng-view,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25746192/

10-10 00:15