javascript - AngularJS Controller not populating -


this code runs on sharepoint web part page in script editor web part. makes ajax call list items sharepoint, , should populating form items. however, nothing happening.

    <link data-require="bootstrap-css@*" data-semver="3.0.0" rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" /> <h2>questionnaire:</h2> <br /> <div ng-app="app">     <div ng-controller="splistctrl">         <table width="100%" cellpadding="10" cellspacing="2" class="employee-table">             <tr ng-repeat="control in controls">                 <td>{{control.title}}</td>                 <td>                     <input type="radio" name="{{control.id}}" value="yes">yes                     <input type="radio" name="{{control.id}}" value="no">no                 </td>                 <td>                     <textarea id="{{control.id}}comment"></textarea>                 </td>             </tr>         </table>     </div> </div> <script src="//code.jquery.com/jquery-1.11.2.min.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-route.js"></script> <script>     function getdatawithcaml(listname, caml) {         var endpoint = "https://myteamsite.sharepoint.com/_api/web/lists/getbytitle('" + listname + "')/getitems(query=@v1)?@v1={\"viewxml\":\"'" + caml + "'\"}";         return jquery.ajax({             url: endpoint,             method: "post",             headers: {                 "x-requestdigest": $("#__requestdigest").val(),                 "accept": "application/json;odata=verbose",                 "content-type": "application/json;odata=verbose"             }         });     }      var app = angular.module('app', ['ngroute'])     .controller('splistctrl', function ($scope, $http) {         var caml = "<view><query><where><contains><fieldref name='title' /><value type='text'>c-04</value></contains></where></query></view>";         var jsondata = getdatawithcaml("controls", caml);         jsondata.success(function (data) {             alert('success');             $scope.controls = data.d.results;         });     }); </script> 

since updating scope outside context of angular execution, need wrap assignment in $scope.$apply, such as

$scope.$apply(function() {    $scope.controls = data.d.results; }); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -