Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why $stateProvider doesn't work in ionic real device?

I have declared a state using $stateProvider. The state looks like this:

.state('tabs.chat1', {
    url : "/chat/:id",
    views : {
        'chat1-tab' : {
            templateUrl : "templates/chat1.html",
            controller : "chatController1"
        }
    }

In HTML I have a link with href="/chat/:{{user._id}}. In the browser it works fine, but when I run it on an Android device tells me that the link doesn't exist. Any ideas?

like image 980
onner Avatar asked Sep 28 '22 02:09

onner


2 Answers

Don't directly define href like this while you have ui-sref directive provided by ui-router to create a href dynamically. Mention state name in it and then provide requires params in its JSON, Though other way of fixing it would be href="/chat/{{user._id}} but I don't encourage you to do this.

ui-serf="tabs.chat1(id: user._id)"
like image 199
Pankaj Parkar Avatar answered Oct 03 '22 01:10

Pankaj Parkar


Your Href should look like this

href="#/chat/{{user._id}}"

no need for the : since the : means that it is a variable that will be fed from a link. we use a # because its loading a template not an entire new page.

like image 43
Joe Lloyd Avatar answered Oct 03 '22 02:10

Joe Lloyd