Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Cordova window.open_系统“;在角度异步内容中_Angularjs_Cordova_Cordova 3_Inappbrowser_Ionic Framework - Fatal编程技术网

Angularjs Cordova window.open_系统“;在角度异步内容中

Angularjs Cordova window.open_系统“;在角度异步内容中,angularjs,cordova,cordova-3,inappbrowser,ionic-framework,Angularjs,Cordova,Cordova 3,Inappbrowser,Ionic Framework,我正在创建一个类似feed的应用程序(ionic sdk:cordova/angular)。应用程序从异步API端点加载基于html的消息。如何转换或捕获包含的锚href,以便将它们转换为“\u系统”新窗口,而不是我正在使用的应用程序窗口 I连接模型(简化): 。。。我有我的指示: app.directive('a', function() { return { restrict: 'E', link: function(scope, elem, attr

我正在创建一个类似feed的应用程序(ionic sdk:cordova/angular)。应用程序从异步API端点加载基于html的消息。如何转换或捕获包含的锚href,以便将它们转换为“\u系统”新窗口,而不是我正在使用的应用程序窗口

I连接模型(简化):

。。。我有我的指示:

app.directive('a', function() {
    return {
        restrict: 'E',
        link: function(scope, elem, attrs) {

            console.log("a href identified");

            // Do the window.open(attrs.href, '_system'); stuff...
        }
    };
});

指令不会对动态加载的html做出响应。

ng bind html
不会编译html内容-它会直接将其添加到文档中

不要使用它,而是创建自己的活页夹:

.directive('myOwnBinder', function($compile, $timeout){
    return {
      restrict: 'E',
      scope: {
        source: '='
      },
      link: function(scope, element, attrs) {
        scope.$watch('source', function(newVal, oldVal) {
          if (newVal === oldVal) return;
          element.html(newVal);
          $compile(element.contents())(scope);
        });
      }
    }
})
。。。并像这样使用它:

<my-own-binder source="link"></my-own-binder>


干杯,马克。你的演示确实让我走上了正确的轨道。我必须承认,安格拉斯经常会弄乱我的脑袋,这是来自于后座。
.directive('myOwnBinder', function($compile, $timeout){
    return {
      restrict: 'E',
      scope: {
        source: '='
      },
      link: function(scope, element, attrs) {
        scope.$watch('source', function(newVal, oldVal) {
          if (newVal === oldVal) return;
          element.html(newVal);
          $compile(element.contents())(scope);
        });
      }
    }
})
<my-own-binder source="link"></my-own-binder>