2017-06-17 11 views
0

私はメインモジュールを持っており、そこにいくつかのルートがあります。 私はいくつかのモジュールを持っており、それらはすべて私のメインモジュールに含まれています。私のホームモジュールの機能の1つでは、私はルーティングしようとしていますが、エラーが発生しています。同じアプリの他の機能が完全にルーティングされている場所ですそれは半日であり、それでも解決できません。以下のコードとエラースタックは任意のヘルプは素晴らしいだろうしてくださいです角度で正しくルーティングを呼び出す方法は?

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) 
 

// EDIT: は、私は非常に密接に観察し、ブラウザのパスを1秒間変更してから '/'に戻ります。

答えて

0

最後に解決策が見つかりました。それは愚かな間違いだった..関数を呼び出すときに私はhref = "#"と同様にコードを配置していた。ここを見てくれてありがとう。私はこれが他の新しい初心者に役立つことを願っています

関連する問題