question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use resolve

See original GitHub issue

Guys, with this syntax:

$stateProvider
        .state('home', {
            url: '/',
            template: '<home></home>'
        });

It’s possible to use resolve? Or do we need a controller property in the state in order to use it?

Thank you.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:48 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
albert5287commented, Jun 17, 2016

Hi guys,

if someone is still interesting, I made it work using ui-router 1.0.0-alpha.5, and following ToddMotto styleguide.

and this is how the code shoud look like

/* ----- todo/todo.component.js ----- */
import template from './todo.html';
import controller from './todo.controller';

const TodoComponent = {
  bindings: {
    todoData: '<'
  },
  controller,
  template: template
};
export default TodoComponent;
/* ----- todo/todo.controller.js ----- */
class TodoController {
  constructor() {
      "ngInject";
      console.log('this is the data from resolve', this.todoData);
  }
}

export default TodoController;
/* ----- todo/index.js ----- */
import angular from 'angular';
import TodoComponent from './todo.component';

const todo = angular
  .module('todo', [])
  .component('todo', TodoComponent)
  .config(($stateProvider, $urlRouterProvider) => {
    "ngInject";
    $stateProvider
      .state('todos', {
        url: '/todos',
        component: 'todo',
        resolve: {
          todoData: PeopleService => PeopleService.getAllPeople();
        }
      });
    $urlRouterProvider.otherwise('/');
  })
  .name;

export default todo;

hope this help.

1reaction
ghostcommented, Apr 13, 2017

That’s not the appropriate way to use it. look at this https://toddmotto.com/angular-1-5-lifecycle-hooks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve Carpet Cleaner Stain Remover - Directions for Me
Directions for use: 1. Spray area with Resolve®. 2. Wait five minutes. 3. Blot or rub gently with a clean, damp, colorfast cloth...
Read more >
Resolve® Heavy Traffic Foam Carpet Cleaner
1. SHAKE CAN WELL. Hold can upside down about 2 feet above carpet. Spray foam evenly over a 3-foot square area. · 2....
Read more >
How to Remove Carpet Stains with Resolve (Review & Test)
ABSORB AS MUCH OF THE STAIN AS POSSIBLE · ABSORB AS MUCH OF THE STAIN AS POSSIBLE · ABSORB AS MUCH OF THE...
Read more >
How To Use Resolve Spot and Stain Carpet Cleaner - YouTube
How To Use Resolve Spot and Stain Carpet Cleaner__________________________________________________New Giveaway Channel: ...
Read more >
DaVinci Resolve - COMPLETE Tutorial for Beginners! - YouTube
Learn how to edit videos with DaVinci Resolve, including all the video editing features & tips you NEED to know as a beginner...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found