Giter Site home page Giter Site logo

anticipate's People

Contributors

andrewyu0 avatar

Watchers

 avatar  avatar

anticipate's Issues

Omit 'http://' protocol scheme for links to show

Protocol has to be defined correctly for the links to show. Change this so links without http:// will work

E.g.

As a user I want to be able to post www.espn.com
Currently requires user to input http://www.espn.com

Look into whether resolve objects need to be injected

In angularApp.js, looks like this is working fine:

.state('home', {
    url         : '/home',
    templateUrl : '/home.html',
    controller  : 'MainCtrl',
    resolve     :  ['postsService', function(postsService){
            return postsService.getAll();
        }]
})

vs

.state('home', {
  url: '/home',
  templateUrl: '/home.html',
  controller: 'MainCtrl',
  resolve: {
    postPromise: ['posts', function(posts){
      return posts.getAll();
    }]
  }
})

without having to inject postPromise into the controller. Look into whether or not this is ok

GET single post: Look into resolve naming, and effect on success() vs then()

This works fine:

state:

.state('posts', {
    ...
    resolve     :  ['$stateParams','postsService', function($stateParams, postsService){
        return postsService.getOne($stateParams.id)
        }] 
});

postsService.getOne:

output.getOne = function(postId){
        return $http.get('/posts/' + postId).success(function(currentPost){
            output.currentPost = currentPost;
        });
    };

in PostsCtrl:
$scope.post = postsService.currentPost;

However, in order to use a named resolve, and inject that resolve in the controller, the state/service needs to be formatted as such:

State:

resolve     : {
    currentPost : ['$stateParams','postsService', function($stateParams, postsService){
        return postsService.getOne($stateParams.id)
    }] 
}

postsService.getOne

output.getOne = function(postId){
    return $http.get('/posts/' + postId).then(function(res){
        return res.data;
    });
};

In order to do the following in the controller:


app.controller('PostsCtrl', [
'$scope',
'currentPost',
function($scope, currentPost){

    $scope.post = currentPost

}]);

Not sure why... I have a feeling it has to do with the res thats coming back from the GET, it's still in the req/res paradigm, which I think I had to use then() vs success(). Check out a resource like this: To then() or to success() in AngularJS

Action item : Create new branch and experiment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.