0

I have a main module and in it are some routes. i have a few more modules and all of those are included in my main module. From one of my home module function, I am trying to route but getting error. where as other function on same app is routing perfectly. It has been half the day and still can not resolve. Below is the code and error stack Please any help would be great

  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 : I observed very closely ; it changes path in browser for a second but then comes back.. to '/'

nimra asad
  • 179
  • 6
  • 18

1 Answers1

0

Finally I found the solution. It was a stupid mistake.. I was placing href="#" as well with my code when calling function.. There fore it was a mess. Any ways thanks much for looking here. I hope this helps any other new beginner

nimra asad
  • 179
  • 6
  • 18