Coder Social home page Coder Social logo

Comments (7)

eight04 avatar eight04 commented on June 7, 2024

I don't use TypeScript, also I don't know how does it resolve dependencies. In node.js, require("custom-input") returns an object exported by custome-input/index.js. If you need the Angular module, you have to require("custom-input/build/custom-input").

There is also a custom-input/dist/custom-input.js, which can be used in the browser.

from angular-datetime.

mattiLeBlanc avatar mattiLeBlanc commented on June 7, 2024

Its just like es6, you use imports at the top of your module.

from angular-datetime.

eight04 avatar eight04 commented on June 7, 2024

Then, does import "custom-input/build/custom-input" work?

from angular-datetime.

mattiLeBlanc avatar mattiLeBlanc commented on June 7, 2024

I did try adding
import 'custom-input';
which is a valid import for the package but that didn't resolve.
Also since custom-input is a dependency of your module and already included, I find it hard to believe that I have to import it myself.
I am a bit puzzled.

from angular-datetime.

eight04 avatar eight04 commented on June 7, 2024

A "valid import" doesn't means that it will do anything to AngularJS. To make a module work with AngularJS, you have to register a module with angular.module() likes your

angular.module( 'prospaDynamicForm.components', ...

custom-input itself is not a AngularJS module, which means:

  1. It can work without Angular
  2. It does nothing to Angular

So what you are going to do is, to register a Angular module for it:

import customInput from 'custom-input';
angular
	.module('custom-input', [])
	.factory('customInput', () => customInput);

And that is what custom-input/build/custom-input.js do.

from angular-datetime.

eight04 avatar eight04 commented on June 7, 2024

When you say

custom-input is a dependency of your module and already included

Which may represent 2 things:

  1. custom-input is inside the dependency list in package.json

    If it is inside package.json, it just tells npm that "Please download custom-input after downloading angular-datetime-input, because angular-datetime-input needs it". Still, it does nothing to Angular.

  2. custom-input is inside the dependency list in angular-datetime-input's angular module

    What it does is to tell Angular: "I need to use custom-input, you should initiate it first for me". But unless you have registered a custom-input module, Angular will just tell you that 'custom-input' is not in its registry.

from angular-datetime.

mattiLeBlanc avatar mattiLeBlanc commented on June 7, 2024

src: dist/datetime.js
angular.module("datetime", ["custom-input"]);

aren't you adding it yourself to your own module? So why would I have to add it if I install your module and add this as a dependency?
Isn't it the whole deal with modules that they are little sell sufficient shells with their own dependencies?
Anyway, if it is something we need to do because your module requires it, please add it to the readme file?

Cheers

from angular-datetime.

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.