0
我有一個主要的模塊,並在它有一些路線。 我有更多的模塊,所有這些都包含在我的主模塊中。從我的家庭模塊功能之一,我試圖路由,但得到錯誤。與其他功能相同的應用程序完美路由。它已經過了半天,仍然無法解決。下面是代碼和錯誤堆棧請任何幫助將是巨大的如何正確調用角度路由?
var app = angular.module("mainModule", ['ngRoute','homeModule']);
app.config(function($routeProvider) {
$routeProvider
.when("/", {
controller : "homeController",
templateUrl : "main.html"
})
.when("/ac-repair", {
templateUrl : "views/ac-service-repair.html",
controller : "formController"
})
});
//home module
var app = angular.module("homeModule", ['ngRoute']);
app.controller("homeController", function ($scope, $http, $location, $rootScope) {
$scope.$watch("selectedService", function (newValue, oldValue) {
// your code goes here...
if (newValue != oldValue) {
var name = $scope.selectedService.name;
if (name == "AC Service & Repair") {
//working fine here
$location.path('/ac-repair');
return;
}
}
});
////
//not working route in this function
$scope.serviceClicked=function(name)
{
if (name == 'AC Service & Repair') {
console.log("reached here!!");
$location.path('/ac-repair');
return;
}
}
});
// error
Uncaught Error: Syntax error, unrecognized expression: [name=]
at Function.ga.error (jquery.min.js:2)
at ga.tokenize (jquery.min.js:2)
at ga.select (jquery.min.js:2)
at Function.ga [as find] (jquery.min.js:2)
at r.fn.init.find (jquery.min.js:2)
at r.fn.init (jquery.min.js:2)
at r (jquery.min.js:2)
at HTMLAnchorElement.<anonymous> (<anonymous>:6:43)
at HTMLAnchorElement.dispatch (jquery.min.js:3)
at HTMLAnchorElement.q.handle (jquery.min.js:3)
//編輯: 我觀察到非常密切;它改變了瀏覽器的路徑一秒鐘,但後來回來..'/'