Amila Sampath
Amila Sampath

Reputation: 645

How to change window open url in ionic?

I am developing ionic application and I added follow plug in

cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git

When click above URL successfully loading application

<a href="#" onclick="window.open('http://192.168.8.157:8081/temp/001', '_system', 'location=yes'); return false;">                            
    Open Application
</a>

But problem is,

If I put http://192.168.8.157:8081/temp/{{id}}

error

Error: [$compile:nodomevents] Interpolations for HTML DOM event attributes are disallowed.  Please use the ng- versions (such as ng-click instead of onclick) instead.
http://errors.angularjs.org/1.4.3/$compile/nodomevents
    at http://localhost:8100/lib/ionic/js/ionic.bundle.js:13380:12
    at attrInterpolatePreLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21823:25)
    at invokeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21962:9)
    at nodeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21441:11)
    at compositeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20853:13)
    at compositeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20857:13)
    at publicLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20728:30)
    at boundTranscludeFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:20872:16)
    at controllersBoundTransclude (http://localhost:8100/lib/ionic/js/ionic.bundle.js:21489:18)
    at ngRepeatAction (http://localhost:8100/lib/ionic/js/ionic.bundle.js:40504:15) <a class="item ng-binding" href="#" onclick="window.open('http://192.168.8.157:8081/temp/'{{id}}, '_self', 'location=no'); return false;">

if you not clear comment, Thank you

Upvotes: 1

Views: 1164

Answers (2)

Amila Sampath
Amila Sampath

Reputation: 645

This is one of solution use ng-href,

<a class="item" ng-href="http://192.168.8.157:8081/temp/{{id}}" onclick="window.open(this.href, '_self', 'location=no'); return false;">
    Open Application
</a>

Reference : link,

Tutorial comment 1st comment.

Upvotes: 1

Vamsi
Vamsi

Reputation: 9780

Its not replacing the {{id}}

So, you can do something like this

<a ng-click='openApplication()'></a>

$scope.openApplication = function () {
    window.open('http://192.168.8.157:8081/temp/'+ $scope.id, '_system', 'location=yes');                            
};

assuming $scope.id has the value that you need

Upvotes: 3

Related Questions