Search code examples
javascriptangularjsionic-frameworkionic-view

ui-sref not working on ionicview, but works on browser, device and emulator


I use ionic for developing an application. There are lots of links and they all work fine. Only in a specific list, the links are not working just in ionicview. The html is:

    <ion-list class="indexed-list">
        <ion-item
            class="item item-avatar"
            ng-repeat="item in categoriesEntity"
            ui-sref="app.entityListSubCategory({subCategoryId: item.id})"
        >
            <img src="img/ionic.png">
            <h2 ng-bind="item.name"></h2>
            <span
                class="header assertive"
                ng-if="item.name.substr(0, 1) !== categoriesEntity[$index - 1].name.substr(0, 1)"
                ng-bind="item.name.substr(0, 1)"
            ></span>
        </ion-list>
    </ion-list>

I works fine in browser, emulator and device. I tried to replace ui-sref by ng-click="alert('hello')" and it was working. I also tried to move/copy ui-sref to img and h2 tags but they wasn't working, too. I also tried replacing ui-sref by ng-click and using $state service to change route, but it was not working, too.

I log my JS errors to server. No JS errors occur when I tap on ion-item.


Solution

  • It's because I wrote a slash before the template name in ui-router :-(