2016-01-29 66 views
1

我開發離子應用程序,我在如何在離子中更改窗口打開url?

添加後續插件科爾多瓦插件添加https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git

當點擊上面的網址成功加載應用程序

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

但問題是,

如果我把http://192.168.8.157:8081/temp/{{id}}

錯誤

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;"> 

,如果你不明確的評論,謝謝

回答

3

它不是更換{{id}}

所以,你可以做這樣的事情

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

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

假設$scope.id有價值,你需要

+0

謝謝你的回答,但這是控制器的實現,我需要查看器 –

1

這是解決方案使用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> 

參考:link

教程評論1日評論。

相關問題