AngularJS navigation

Ich versuche zum implementieren einer navigation in einer Webseite mithilfe von angularJS. Das problem ist, dass der Weg gar nicht mehr funktioniert. Die browser-Konsole gibt keine Fehler und die ng-view einfach nicht zeigen, das templatesUrls.

route.js

   var routeApp = angular.module('myApp', ['ngRoute']);

routeApp.config(function($routeProvider) {
    $routeProvider
        .when('/', {
            templateUrl: 'partials/task.html',
            controller: 'TraineesController'
        })
        .when('/technology', {
            templateUrl: 'partials/technology.html',
            controller: 'TraineesController'
        })
.otherwise({redirectTo:"/technology"});

});

Index.html

<html ng-app="myApp">
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="css/taskman.css"/>
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,700" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular-route.js"></script>
<script type="text/javascript" src="app/route.js"></script>
<script type="text/javascript" src="app/app.js"></script>
</head>
<body>
<a href="#/technology" class="btn btn-sm btn-danger nav-button-margin">
  <i class="glyphicon glyphicon-user"></i>&nbsp;Account panel
</a>
<div class="col-sm-12">
  <div ng-view></div>
</div><!-- Closing col-sm-12-->
</body>
</html>

app.js

var app = angular.module('myApp', []);

app.controller('TraineesController', function($scope, $http, $log) {
  getTrainee(); //Load all available tasks

  function getTrainee(){  
  $http.post("ajax/getTrainee.php").success(function(data){
        $scope.trainees = data;
       });
  };
});

task.html

<div class="widget-box" id="recent-box" ng-controller="TraineesController">
Random text tables
</div>
  • Nicht mit dem gleichen controller auf den Körper und die route.
  • Entfernen von ng-controller-tag aus Körper, seine bereits in route.js
  • Aktualisiert die Frage immer noch das gleiche problem. <div ng-include src="'partials/task.html'"></div> scheint zu funktionieren, aber nicht das ng-view
InformationsquelleAutor Spinxas | 2014-08-21
Schreibe einen Kommentar