Giter VIP home page Giter VIP logo

Comments (15)

urish avatar urish commented on July 24, 2024

Can you try to change the import to

import {TimeAgoPipe} from 'angular2-moment/TimeAgoPipe.js';

and see if it helps?

from ngx-moment.

 avatar commented on July 24, 2024

thanks you so much

2016-02-02 5:18 GMT+07:00 Uri Shaked [email protected]:

Can you try to change the import to

import {TimeAgoPipe} from 'angular2-moment/TimeAgoPipe.js';

and see if it helps?


Reply to this email directly or view it on GitHub
#11 (comment)
.

                         Bùi Ngọc Phú

                         Mail:[email protected]

                         Phone: 0901 443 593

from ngx-moment.

danielgolub avatar danielgolub commented on July 24, 2024

Hi,

I have the same bug. (even when I use @urish solution)

from ngx-moment.

urish avatar urish commented on July 24, 2024

@danielgolub are you using typescript?
have you got the latest release of angular2-moment (that is version 0.3.0)

from ngx-moment.

danielgolub avatar danielgolub commented on July 24, 2024

@urish Yes.
I just installed it few minutes ago.

from ngx-moment.

urish avatar urish commented on July 24, 2024

Can you please include the output that you get?

from ngx-moment.

danielgolub avatar danielgolub commented on July 24, 2024

When using the import code from the README file:
image

When using the solution your wrote in this chat earlier:
image

from ngx-moment.

urish avatar urish commented on July 24, 2024

seems to be a configuration problem. When you go to http://localhost:3000/angular2-moment, do you see the code of the module or a 404 error page?

from ngx-moment.

danielgolub avatar danielgolub commented on July 24, 2024

404 error page.

from ngx-moment.

urish avatar urish commented on July 24, 2024

I would suggest to check your configuration, if you are using system.js you need to configure the module loader correctly so that it can correctly locate the angular2-moment package inside your node_modules directory.

from ngx-moment.

danielgolub avatar danielgolub commented on July 24, 2024

Well I followed the "Hero" setup on angular.io website.
Here are the different configuration files I have:

tsconfig.json:

{
  "compilerOptions": {
    "target": "ES5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules"
  ]
}

package.json:

{
  "name": "SHIELDoX",
  "version": "1.0.0",
  "scripts": {
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
  },
  "license": "ISC",
  "dependencies": {
    "angular2": "2.0.0-beta.0",
    "angular2-moment": "^0.3.0",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",
    "systemjs": "0.19.6",
    "zone.js": "0.5.10"
  },
  "devDependencies": {
    "concurrently": "^1.0.0",
    "lite-server": "^1.3.1",
    "typescript": "^1.7.3"
  }
}

And on index.html:

        <!-- 2. Configure SystemJS -->
        <script>
          System.config({
            packages: {
              app: {
                format: 'register',
                defaultExtension: 'js'
              }
            }
          });
          System.import('app/boot')
                .then(null, console.error.bind(console));
        </script>

from ngx-moment.

urish avatar urish commented on July 24, 2024

Can you please upload the entire code to a git repo?

from ngx-moment.

danielgolub avatar danielgolub commented on July 24, 2024

@urish, I added you as a collaborator on the git repo.

from ngx-moment.

urish avatar urish commented on July 24, 2024

Seems like the following System.js configuration should do the trick for you:

System.config({
    packageConfigPaths: ['node_modules/*/package.json'],
    paths: {
        'moment': '/node_modules/moment',
        'angular2-moment/*': '/node_modules/angular2-moment/*',
    },
    packages: {
        app: {
            format: 'register',
            defaultExtension: 'js'
        }
    },
    meta: {
        moment: {
            format: 'global',
            globals: {
                moment: 'moment'
            }
        }
    }
});

And then, import the module as follows:

import {TimeAgoPipe} from 'angular2-moment/TimeAgoPipe.js'; 

In general, I would suggest to study System.js in detail if you intend to use it in your project, it will save you much time in the future.

from ngx-moment.

danielgolub avatar danielgolub commented on July 24, 2024

It works.
Anyway, I will read some more articles about System.js. It seems I was too enthusiastic about Angular2 that I ran too fast :P

Thanks.

from ngx-moment.

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.