My Wiki!

Angularjs beginner

Rest Services

AngularJS Promisses

Nested objects

So after a lot of looking around I've learned the answer to at least my original question. And angularjs truly does handle it beautifully. Basically by adding an ng-controller to an item with ng-repeat you can now play with the items on an item by item basis. Full example code with my solution is below if anyone is interested.

//index.html
 
<!doctype html/>
<html ng-app="restApp" ng-controller="mainController">
  <head>
    <title>Get Comments from Topic</title>
  </head>
  <body>
    <div ng-repeat="topic in topics" ng-controller="topicController">
      <h1>{{ topic.topic_title }}</h1>
      <div ng-repeat="comment in comments">
        <h3>{{ comment.comment }}</h3>
        <p>{{ comment.author_name }}</p>
      </div>
    </div>
    <script type="text/javascript" src="js/lodash.min.js"></script>
    <script type="text/javascript" src="js/angular.min.js"></script>
    <script type="text/javascript" src="js/restangular.js"></script>
    <script type="text/javascript" src="app.js"></script>
  </body>
</html>

My controllers:

// app.js
 
var app = angular.module("restApp", ["restangular"]);
 
app.config(
  function(RestangularProvider){
    RestangularProvider.setBaseUrl('http://api.example.com/v1');
    RestangularProvider.setDefaultHeaders({"Authorization": "..."});
  }
);
 
app.config(function($httpProvider) {
  $httpProvider.defaults.useXDomain = true;
  delete $httpProvider.defaults.headers
    .common['X-Requested-With'];
});
 
app.controller("mainController", ["Restangular","$scope", function(Restangular, $scope){
  $scope.message = "Welcome to REST";
  var topics = Restangular.all('topics');
  var allTopics = topics.getList().then(function(topics){
    $scope.topics = topics;
    console.log($scope.topics);
  });
}]);
 
app.controller("topicController", ["Restangular", "$scope", function(Restangular, $scope){
  var oneTopic = Restangular.one('topics', $scope.topic.id);
  oneTopic.get().then(function(topic) {
    topic.getList('comments').then(function(comments){
      $scope.comments = comments;
      console.log($scope.comments);
    });
  });
}]);


Login

UI: Nested views, ui-router, ui-bootstrap

ui-router parameter

watch


Navigation