I select an option from dropdown menu. The event handler is called successfully wherein I request for a new page asynchronously using $http GET method of angular.
<script> function fun1($scope, $http){ $scope.options="options" $scope.option1="option1" $scope.onChangeHandler=function(arg1){ $http({ method: 'GET', url: "/someurl" }).then(function successCallBack(responsedata){ $scope.response = responsedata.data },function errorCallBack(response){ alert("Error!"); }); } var myApp = angular.module("myApp", [ngSanitize]); myApp.controller("fun1", fun1); myApp.config(function($interpolateProvider){ $interpolateProvider.startSymbol("[[") $interpolateProvider.endSymbol("]]") }); } </script> <body ng-app="myApp" ng-controller="fun1"> <div> <select class=target id="option" ng-model="options", ng-change="onChangeHandler(options);"> <option ng-model="option1">Option1</option> </select> <div id=result ng-bind-html="response"></div> </div> </body>
Response page again has some angular elements like a table with ng-repeat etc.
<script> function fun1($scope, $http){ $scope.data=[{name: 'name1', age: 20}, {name: 'name2', age: 25}]; } var myApp = angular.module("myApp", []); myApp.controller("fun1", fun1); myApp.config(function($interpolateProvider){ $interpolateProvider.startSymbol("[[") $interpolateProvider.endSymbol("]]") }); </script> <body ng-app="myApp"> <div ng-controller="fun1"> <table> <thead> <tr> <th>Name</th> <th>Age</th> </tr> </thead> <tbody> <tr ng-repeat="usr in data"> <td>[[usr.name]]</td> <td>[[usr.age]]</td> </tr> </tbody> </table> </div> </body>
Sent this reponse using django render method:-
return render(request, someurl.html)
4.Response returned successfully but rendered as plain test in a target div. That includes even [[**]] expressons of angular as below:-
Name Age
[[usr.name]] [[usr.age]]
- Configured expression syntax from {{...}} to [[...]] intentionally to avoid conflict with django template tags.
Q1. Why angular not working in response? No error on chrome dev console but actual values in table not populated. What concept I'm missing?
Q2. What other options are there to render angular response similar to ng-bind-html.