我正在开发离子应用程序,我添加了以下插件
科尔多瓦插件添加 https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
单击上面的URL成功加载应用程序时
<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;">
如果您不清楚评论,谢谢
它不会取代{{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
具有您需要的值
这是
解决方案使用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>
参考 : 链接,
教程评论第一条评论。