angularjs - Access $scope outside the controller -
i want access object in function within controller.
here controller, in controller have function called 'fetchall';
app.controller('testcontroller', ['$scope', '$http', function($scope, $http, $log) { $scope.fetchall = function() { $http({ method: 'post', url: 'xxx', data: testarray, headers: {'content-type': 'application/json'} }).success(function(data) { $scope.testobj = data; }).error(function(data, status, headers, config) { }) }
}])
i want access $scope.testobj in index.html, since want display content.
any help point me in right direction appreciated.
i'll reply question myself, comments helped me figure out.
the confusing part me had object in function within controller, didn't matter @ all.
<div ng-controller="testcontroller" <ul> <li>{{testobj}}</li> </ul> </div>
angularjs
No comments:
Post a Comment