Coder Social home page Coder Social logo

Comments (5)

tiagobbraga avatar tiagobbraga commented on May 21, 2024

In a way, I got the project rolling.

I changed the public folder systemjs.config.js

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': '/assets/'
    },
    // map tells the System loader where to look for things
    map: {
      // our application is within the app folder
      app: 'app',
      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
      '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'angular2-token.model': 'npm:angular2-token/lib/angular2-token.model.js',
      'angular2-token.service': 'npm:angular2-token/lib/angular2-token.service.js'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

app.module.ts from the public / app folder

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }  from '@angular/forms';
import { HttpModule }    from '@angular/http';

import { AppRoutingModule } from './app-routing.module';

import { AppComponent } from './app.component';
import { HeroDetailComponent } from './hero-detail.component';
import { HeroesComponent } from './heroes.component';
import { DashboardComponent } from './dashboard.component';
import { HeroSearchComponent } from './hero-search.component';
import { HeroService } from './hero.service';

import './rxjs-extensions';

import { Angular2TokenService } from 'angular2-token.service';

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    AppRoutingModule
  ],
  declarations: [
    AppComponent,
    HeroDetailComponent,
    HeroesComponent,
    DashboardComponent,
    HeroSearchComponent
  ],
  providers: [ HeroService, Angular2TokenService ],
  bootstrap: [ AppComponent ]
})

export class AppModule { }

app.components.ts from the public / app folder

import { Component } from '@angular/core';

import { Angular2TokenService } from 'angular2-token.service';

@Component({
  moduleId: module.id,
  selector: 'my-app',
  template: `
              <h1>{{title}}</h1>
              <nav>
                <a routerLink="/dashboard" routerLinkActive="active">Dashboard</a>
                <a routerLink="/heroes" routerLinkActive="active">Heroes</a>
              </nav>
              <router-outlet></router-outlet>
          `,
  styleUrls: ['app.component.css'],
})

export class AppComponent {
  title = 'Tour of Heroes';

  constructor(private _tokenService: Angular2TokenService) {
    this._tokenService.init();

    console.log('logged '+this._tokenService.userSignedIn());
  }
}

I just do not know if this is the best way ...

Complete Code
branch: authentication

That's the best way?

from angular-token.

neroniaky avatar neroniaky commented on May 21, 2024

Hey @tiagobsbraga thanks for your detailed explanation.

After even angular-cli switched to webpack I did not do tests with SystemJS anymore. But seems like quite a lot of people try to make it work with the angular2 tutorial. Maybe I should add webpack as a requirement to the README until this I have the time to get this fixed.

Suggestions?

from angular-token.

tiagobbraga avatar tiagobbraga commented on May 21, 2024

So... I guess that we can try, do not you think?

I was not too keen on new things for the web, my focus today is more on developing mobile devices natively.

from angular-token.

volpejoaquin avatar volpejoaquin commented on May 21, 2024

I have the same error with https://github.com/mgechev/angular-seed and angular2-token. Could you give me a solution please?.

I'm trying do the following:

File
https://github.com/mgechev/angular-seed/blob/master/tools/config/project.config.ts
Changes

// Add packages (e.g. angular2-token)
let additionalPackages: ExtendPackages[] = [
  {
    name: 'angular2-token.service',
    // Path to the package's bundle
    path: 'node_modules/angular2-token/lib/angular2-token.service.js'
  }
];
this.addPackagesBundles(additionalPackages);

File
https://github.com/mgechev/angular-seed/blob/master/src/client/app/app.component.ts
Changes

import { Angular2TokenService } from 'angular2-token.service';
console.log(Angular2TokenService);

And also have the same error:

Error: (SystemJS) Unexpected token <

from angular-token.

neroniaky avatar neroniaky commented on May 21, 2024

Should be fixed in the latest build. Please reopen if problem still persists.

from angular-token.

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.