angular-fullstack / generator-angular-fullstack

Yeoman generator for an Angular app with an Express server
https://awk34.gitbook.io/generator-angular-fullstack
6.12k stars 1.24k forks source link

How to make todo view? #1074

Closed luckylooke closed 9 years ago

luckylooke commented 9 years ago

Let say that I put hrefs into todo list:

<a href="/todos/developement-tools" tooltip="..." >Development Tools</a>

So I get to one todo view. How can I make it work?

Thanks

Awk34 commented 9 years ago

First of all, I don't really know what you're trying to ask. You need to be a lot more specific with more details. Second of all, from what I can tell, this is a question that belongs on Stack Overflow

kingcody commented 9 years ago

@luckylooke I'm not sure what "todos" you are speaking of. Also you haven't told use anything about your setup or what you would like to accomplish. If you could fill in some details it would be more likely that someone may be able to help you (:

luckylooke commented 9 years ago

I have posted it here because I thought it is simple question for experienced angular-fullstack users. On stackoverflow they would need to become familiar with angular fullstack. Anyway I can also try there.

All I need is to create routing for urls (like /todos/selected-todo) to views with one todo selected in fresh generated angular-fullstack demo page. Genersted page have list of todos under yeoman logo on main page.

I hope you understand me now :) Thanks On Jul 18, 2015 12:48 AM, "Cody Mize" notifications@github.com wrote:

@luckylooke https://github.com/luckylooke I'm not sure what "todos" you are speaking of. Also you haven't told use anything about your setup or what you would like to accomplish. If you could fill in some details it would be more likely that someone may be able to help you (:

— Reply to this email directly or view it on GitHub https://github.com/DaftMonk/generator-angular-fullstack/issues/1074#issuecomment-122438669 .

luckylooke commented 9 years ago

Ok, I dont know why I was talking about todos... there are FEATURES alias things, I am so sorry for misleading.. I have managed it somehow, just check if it makes sense.

I have augmented server/api/thing/thing.model to have new link property:

var ThingSchema = new Schema({
  name: String,
  link: String,
  ...
});

I have put links strings into server/config/seed.js

Thing.find({}).remove(function() {
    Thing.create({
        link: 'developement-tools',
        name: 'Development Tools',
        info: 'Integration ... Less.'
    },
...
 );
});

I have edited hrefs in client/main/main.html

<h1 class="page-header">Features:</h1>
      <ul class="nav ..." ng-repeat="thing in awesomeThings">
        <li><a href="/features/{{thing.link}}" tooltip="{{thing.info}}">{{thing.name}}...</a></li>
      </ul>

I have created new state in client/main/main.js

$stateProvider
      .state('main', {
        ...
      })
      .state('thing', {
        url: '/features/:link',
        templateUrl: 'app/main/thing.html',
        controller: 'ThingCtrl'
      });

Then I have created thing controller in client/main/thing.controller.js

angular.module('myApp')
  .controller('ThingCtrl', function ($scope, $http, socket, $stateParams) {
    $scope.thing = {};

    $http.get('/api/things/' + $stateParams.link).success(function(thing) {
      $scope.thing = thing[0];
      socket.syncUpdates('thing', $scope.thing);
    });

    $scope.$on('$destroy', function () {
      socket.unsyncUpdates('thing');
    });
  });

and thing view in client/main/thing.html

<div class="container">
  <div class="row">
    <div class="col-lg-12">
      <h1 class="page-header">Thing(todo) properties:</h1>
      <ul class="nav nav-tabs nav-stacked col-md-4 col-lg-4 col-sm-6">
        <li>link: {{thing.link}}</li>
        <li>name: {{thing.name}}</li>
        <li>info: {{thing.info}}</li>
      </ul>
    </div>
  </div>
</div>
luckylooke commented 9 years ago

It was pretty complicated for me, as I was pure front-end focused in past and I am just beginner in back-end. There should be some basic examples/tutorials of using angular-fullstack maybe. Thanks anyway for your time! Have a nice day ;)