With AngularJS, I've implemented an ng-repeat to display object properties. My goal is to access root.TooltipText
in the controller.
Below is the HTML code snippet:
<div id="root">
<div ng-repeat="root in rootresults">
<button type="button" class="btn btn-primary" ng-click="showpagetwo(root.Title, root.ID)" ng-if="root.Location == null">{{root.Title}}
<span class="tooltiptextsmall tooltip-rightsmall" ng-if="root.TooltipSize =='Small'">{{root.TooltipText}}</span>
<span class="tooltiptextnormal tooltip-rightnormal" ng-if="root.TooltipSize =='Normal'">{{root.TooltipText}}</span>
</button>
</div>
</div>
And here is my controller implementation:
var app = angular.module('wizardApp', []);
app.controller('MainCtrl', function($scope, $http, $q){
$(document).ready(function() {
$scope.getRootList();
});
$scope.prepContext = function(url,listname,query){
var path = url + "/_api/web/lists/getbytitle('" + listname + "')/items" + query;
return path;
}
$scope.getRootList = function() {
rootList = $http({
method: 'GET',
url: this.prepContext(siteOrigin+"/divisions/testing","SupportList","?$orderBy=Title&$filter=RootItem eq 'Yes'"),
headers: {
"Accept": "application/json; odata=verbose"
}
}).then(function(data) {
//$("#articleSection").fadeIn(2000);
console.log(data.data.d.results);
$scope.rootresults = data.data.d.results;
});
};
});
When logging data.data.d.results
, it shows:
{
"0": {
"Title": "Test1",
"TooltipText": "Test1",
"TooltipSize": "Small"
},
"1": {
"Title": "Test2",
"TooltipText": "Test2",
"TooltipSize": "Small"
},
...
}
Is there a way to access object properties in the controller?