Giter VIP home page Giter VIP logo

Comments (4)

jmdobry avatar jmdobry commented on May 29, 2024 1

Yes, it's a quirk of Angular's dependency injection. The DI system is lazy in that it waits to execute the setup code for the dependency until the dependency is actually needed. So if you don't actually inject Ad or Classified before that route resolve is executed, then those resources actually haven't yet been registered with the data store.

One way I get around it is the inject all my resources into the .run function of my angular app.

from js-data.

kentcdodds avatar kentcdodds commented on May 29, 2024

@demisx, this is how all of my factories look:

.factory('Classified', function(DS) {
  return DS.defineResource({
    name: 'classified',
    endpoint: '/classifieds',
    relations: {
      hasMany: {
        ad: {
          foreignKey: 'adId',
          localField: 'ad'
        }
      }
    }
  });
}).run(function(Classified) {}); // this line

That way the file that creates it also makes sure that it runs :-)

from js-data.

demisx avatar demisx commented on May 29, 2024

@kentcdodds Aha! I like that. Thank you Kent. Would be great to capture this in the docs as well.

from js-data.

techniq avatar techniq commented on May 29, 2024

@kentcdodds Nice tip!

With strictdi = true and (ES6), I use .run(['Classified', () => {}]

from js-data.

Related Issues (20)

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.