Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <!-- search result view -->
  2. <p>size is {{resultCount}}</p>
  3.  
  4. <!-- main view which has ng-view -->
  5. <html ng-app="exApp">
  6. <body ng-controller="exApp.MainCtrl">
  7. <!-- form which submits to SearchCtrl -->
  8. <form name="searchform" ng-controller="exApp.SearchCtrl" ng-submit="search()">
  9. <input type="text" ng-model="queryString">
  10. </form>
  11. <div class="view-panel" ng-view></div>
  12. </body>
  13. </html>
  14.  
  15. exApp.MainCtrl = function ($scope) {
  16. $scope.queryString = '';
  17. $scope.resultCount = 0;
  18. }
  19.  
  20. exApp.SearchCtrl = function ($scope, $http) {
  21. function display(response) {
  22. $scope.poreqs = response["resource"];
  23. // should update the html, but does not
  24. $scope.resultCount = $scope.poreqs.length;
  25. }
  26. $scope.search = function () {
  27. $http.get('/search?q=' + $scope.queryString).success(display);
  28. };
  29. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement