ng-include with templateCache in google chrome extension (Angular 1.5.8)

0

I'm developing an extension for google chrome with angular.

Everything works fine, but when I want to use templateCache with ng-include, it tries to find the path inside the extension's folder and never looks in the templateCache.

<ng-include src = " 'ViewHTML' "></ng-include>

the code that I use to load the view in the templeCache ...

$templateCache.put("ViewHTML","<h1>Working</h1>");

I always use templateCache, but it only stops working when I try to use it with <ng-include>

  

the angle version used is 1.5.8

    
asked by Moisés Godoy 22.07.2016 в 17:51
source

1 answer

2

You have a couple of errors in the code

  • The directive is ng-include no ng-included
  • The names of the views must match. If you wrote 'ViewHTML' you should always reference it like this. In your code you have 'viewHTML' with lowercase. The syntax of $cacheFactory is put('key', value) so the keys must be identical.
  • angular.module('app', [])
      .controller('TestCtrl', function($templateCache) {
        $templateCache.put("ViewHTML", "<h1>Working</h1>");
      });
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
    <div ng-app="app" ng-controller="TestCtrl">
      <ng-include src=" 'ViewHTML' "></ng-include>
    </div>
        
    answered by 22.07.2016 в 21:25