angular-element-4

 

In this example, angular.element append and prepend "LearnKode.Com" and "Welcome". The result will be "Welcome to LearnKode.Com" See the code snippet:

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome in the AngularJS</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="elementController"> <div id="appentPrepend"> to </div> </div> <script> var app = angular.module("app", []); app.controller('elementController', ['$scope', '$document', function ($scope, $document) { var element= angular.element($document[0].querySelector("#appentPrepend")); element.prepend('<b>Welcome</b>'); element.append('<i>LearnKode.Com</i>'); }]); </script> </body> </html>
Output