Push HTML to the view with variable AngularJS

How do I push HTML within the Angular variable?


function myControler($scope){

   $scope.myItem = '<p>' + Test + '</p>';


<div ng-controller="myControler">{{myItem}}</div>


Try using the directive ngBindHtml

angular.module('ngBindHtmlExample', ['ngSanitize'])

.controller('ngBindHtmlCtrl', ['$scope', function ngBindHtmlCtrl($scope) {
  $scope.myHTML =
     'I am an <code>HTML</code>string with <a href="#">links!</a> and other <em>stuff</em>';

More infornation on ngBindHtml: http://docs.angularjs.org/api/ng/directive/ngBindHtml

Or you can create a custom directive: http://docs.angularjs.org/guide/directive http://plnkr.co/edit/ngdoc:example-example83@snapshot?p=preview

Generally, you shouldn't.

It's the view's responsibility to generate HTML. The controller should expose structured data to the view, through the scope. It shouldn't generate HTML.

If that's really not an option, then use the ng-bind-html directive and the $sce service. The example code shows exactly what you want to do.

Need Your Help

Windows Installer and the creation of WiX

wix installer windows-installer orca

We currently use WiX for building our MSI files, and as such it is the only MSI builder I have had experience using. I know you can build installers natively in Visual Studio though. What are the

Echoing a echo command with a variable in bash

bash shell variables echo

Ok, here is one I am struggling with as we speak. Echoing a echo command with a variable.