All the codes I found on any of tutorial was to inject a message string rather than html page. how do I inject html page using ng-view? Say structure of SPA is 2 links "Add" and "View" Add injects add.html and View injects View.html
Asked
Active
Viewed 729 times
-3
-
I would sure like to see those tutorials because any docs on routers (ngroute or ui-router) show how to use templates and templateUrl's. You have been mislead – charlietfl Aug 26 '15 at 10:28
-
This is the official example of `ng-view` and `ng-route` : http://plnkr.co/edit/c4daKMuLef6lgjnSyWIE?p=preview – Pierre-Alexandre Moller Aug 26 '15 at 11:09
1 Answers
0
Using
ng-bind-html
Your HTML code will look like
<div ng-controller="ExampleController">
<p ng-bind-html="myHTML"></p>
</div>
You can bin html in following ways
angular.module('bindHtmlExample', ['ngSanitize'])
.controller('ExampleController', ['$scope', function($scope) {
$scope.myHTML =
'I am an <code>HTML</code>string with ' +
'<a href="#">links!</a> and other <em>stuff</em>';
}]);
It's recommended to bind html rather then htmlpage.

Denish
- 2,800
- 2
- 23
- 33
-
Can you be more ellaborative with example? I found this example on angularjs website. Like I want to bind my html page so in controller instead of giving 'I am an
HTML
string with ' + 'links! and other stuff'; I want to put source of html file – surbhi bakshi Aug 26 '15 at 10:46 -
"It's recommended to bind html rather then htmlpage" I would like to see what is your source for that. – Pierre-Alexandre Moller Aug 26 '15 at 11:06