title: Angular iframe dynamisch: $sce: Cannot Read property of undefined
body: <p>I try to make a word combinator for keywords. After combining them I want to load dynamically google search requests into an iframe. Unfortunately I have some problems with $sce-service.</p>
  
  <p>Errormessage:
  <code>TypeError: Cannot read property 'trustAsUrl' of undefined</code></p>
  
  <pre><code>Same error for $sce.trustAsResourceUrl(...);
  </code></pre>
  
  <p>My plunkr:
  <a href="http://plnkr.co/edit/N2nzBVElPtegaPYUCXlz" rel="nofollow">http://plnkr.co/edit/N2nzBVElPtegaPYUCXlz</a></p>
  
  <p>Important part:</p>
  
  <p>Controller.js</p>
  
  <pre><code>var keywordAppControllers = angular.module('keywordAppControllers', []);
  
  keywordAppControllers.controller('KeywordCtrl', ['$scope','$sce',
    function ($scope) {
      $scope.myData = {};
      $scope.myData.previewUrl="";
  
      $scope.serpPreview = function(keyword, $sce, $scope) {
        previewUrl="https://www.google.de/search?q=" + encodeURIComponent(keyword);
        // previewUrl="https://www.google.de/search?q=" + keyword;
        console.log(previewUrl);
        trustedUrl = $sce.trustAsUrl('https://www.google.de/');
        console.log(trustedUrl);
        // $scope.myData.previewUrl = $sce.trustAsUrl('www.google.de/');
        // $scope.myData.previewUrl = $sce.trustAsUrl('https://www.google.de/');
        // $scope.myData.previewUrl = $sce.trustAsUrl('https://google.de/');
        // $scope.myData.previewUrl = $sce.trustAsUrl('//google.de/');
      };
      // create a blank object to hold our form information
      // $scope will allow this to pass between controller and view
      $scope.formData = {};
    }
  ]);
  </code></pre>
  
  <p>App.js:</p>
  
  <pre><code>var keywordApp = angular.module('keywordApp', [
    'keywordAppControllers'
  ]).config(function($sceDelegateProvider) {
     $sceDelegateProvider.resourceUrlWhitelist([
       // Allow same origin resource loads.
       'self',
       // Allow loading from our assets domain.  Notice the difference between * and **.
       'https://google.de/*',
       'http://google.de/*',
       'https://google.de/**',
       'http://google.de/**'
     ]);
   });
  </code></pre>