Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught Error: Syntax error, unrecognized expression: #/ angularjs and jquery

Following error shown up in my console whenever my page loads.

"Uncaught Error: Syntax error, unrecognized expression: #/about"

My code is as below:

                <li class="active">
                    <a href="/">Home</a>
                </li>
                <li class="">
                    <a href="#/about" title="About Us">About</a>
                </li>
                <li class="">
                    <a href="#/pricing">Pricing</a>
                </li>

It shows for all initial instance of . Initially, it shows for #/about as it is first, If I remove about us tab it will show up for pricing page link.

Its not bootstrap tab issue, This are simple navigation only

Routing Code in app.js:

$routeProvider.when('/', {
        templateUrl: 'partials/home.html'
    }).when('/account', {
        templateUrl: 'partials/account.html',
    }).when('/terms', {
        templateUrl: 'partials/terms.html'
    }).when('/about', {
        templateUrl: 'partials/about.html'
    }).otherwise({
        redirectTo: '/'
    });

I have debug its issue of bootstrap, bootstrap nav causing this issue: "nav navbar-nav" fixes for this is data-target="#" but wants proper work around for this

like image 949
ram Avatar asked Jul 19 '15 05:07

ram


3 Answers

This is most probably a Bootstrap issue. Try using data-targetattribute on your links like this

<a href="#/about" data-target="#about" title="About Us">About</a>
like image 94
Bidhan Avatar answered Oct 23 '22 17:10

Bidhan


Ok you gotta remove the slash, '/' with which your html becomes,

<a href="#about" title="About Us">About</a>

If you want to keep the slash, '/' you gotta use data-target attribute as,

<a href="#/about" title="About Us" data-target="#about">About</a>

More about it here

like image 37
Sudhansu Choudhary Avatar answered Oct 23 '22 17:10

Sudhansu Choudhary


This issue happens also on angular 2 projects. I just add data-target="#" to the anchor link. It solved my problem.

 <a data-target="#" [routerLink]="['/link']">my link</a>. 
like image 28
Miguel Peguero Avatar answered Oct 23 '22 17:10

Miguel Peguero