1
$http.get('template/alert.html', {
    cache: $templateCache
});
$scope.clickedButton = function () {
    console.log($templateCache.info()); // <-- Object {id: "templates", size: 1}
    console.log($templateCache.get('alert.html')); // <-- undefined
    console.log($templateCache.get('template/alert.html')); // <-- undefined
};

So I am trying to aquire the html, put it into the cache and then console.log out the contents of the html file.

2 Answers 2

1
$http.get('template/alert.html', {
    cache: true
}).then(function(resp){
    $templateCache.put('template/alert.html', resp.data)
});
$scope.clickedButton = function () {
    console.log($templateCache.info()); // <-- Object {id: "templates", size: 1}
    console.log($templateCache.get('template/alert.html')); // <-- response
};

This might work for you

Sign up to request clarification or add additional context in comments.

Comments

0

I have solve it using $templateRequest:

$templateRequest(
  'template/alert.html'
);
$scope.clickedButton = function () {
  console.log($templateCache.info()); // <-- Object {id: "templates", size: 1}
  console.log($templateCache.get('template/alert.html')); // <-- response
};

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.