2016-10-09 3 views
1

Ich mag URL (externe URL 'http://google.com') in Dashboard Inhalt laden, habe ich versucht, mit diesem CodeLaden externe URL auf Dashboardinhalt

.state('app.urlloading', { 
    url: '/url-loading', 
    controller:function($window){ 

     $window.location.href = 'https://google.com'; 

    }, 
    templateUrl: 'views/tmpl/url-loading.html' 
    }) 

1) Ist es möglich, eine externe URL in Dashboard Inhalt zu laden ?, Wenn ich auf eine Schaltfläche in der Seitenleiste des Dashboards klicke, sollte nur der Dashboard-Inhalt die URL-beibehaltene Sidebar und den Header anzeigen. Jetzt verschwindet das gesamte Dashboard, nachdem ich auf die Schaltfläche geklickt und zur Google-Seite weitergeleitet habe.

+0

können Sie ein 'iframe' verwenden? –

Antwort

0

Wenn Sie location.href ändern, ganze Seite ändert. Statisches HTML, das aus Zuständen verwendet werden kann, dass statische HTML-Links keine Rolle spielen, ist extern oder nicht.

<div class="wrapper"> 
<div class="h_iframe"> 
    <!-- a transparent image is preferable --> 
    <img class="ratio" src="http://placehold.it/16x9"/> 
    <iframe src="http://www.youtube.com/embed/WsFWhL4Y84Y" frameborder="0" allowfullscreen></iframe> 
</div> 
<p>Please scale the "result" window to notice the effect.</p> 

Aber Sie diese iframes wie das, was Sie genau wollen werden, ist verwenden könnte.

0

Was ist mit einem iframe

url-loading.html

<iframe src="https://google.com"></iframe> 

Wenn Sie template & controller differents URL dieses öffnen möchten, können Sie verwenden ein resolver

// loading google 
.state('app.urlloading', { 
    url: '/url-loading-google', 
    controller:'UrlLoadingCtrl' 
    resolve { 
     url : function(){ 
      return "https://www.google.com" 
     } 
    } 
    templateUrl: 'views/tmpl/url-loading.html' 
    }) 

// loading twitter 
.state('app.urlloading', { 
    url: '/url-loading-twitter', 
    controller:'UrlLoadingCtrl' 
    resolve { 
     url : function(){ 
      return "https://www.twitter.com" 
     } 
    } 
    templateUrl: 'views/tmpl/url-loading.html' 
    }) 

Controller

.controller('UrlLoadingCtrl', [ 'url', '$scope', function(url, $scope){ 
    $scope.url = url; 
}) 

url-loading.html

<iframe src="{{url}}"></iframe>