I am developing an node app with angular2 and gulp. I have written a component file login.ts as follows:
import {Component, View} from \'angular2/angular2\';
you have to Update Angular2 version in final version --
And then use like ----
import { Component } from '@angular/core';
there is a updated library like --- '@angular/core'
Please note that as form Angular2 final release the correct answer is this.
import {Component, View, Directive, Input, Output, Inject, Injectable, provide} from 'angular/core';
import {bootstrap} from 'angular/platform/browser';
import {CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass, NgIf NgForm, Control, ControlGroup, FormBuilder, Validators} from 'angular/common';
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router, LocationStrategy, HashLocationStrategy} from 'angular/router';
import {Http, HTTP_PROVIDERS, RequestOptions, Headers, Request, RequestMethod} from 'angular/http'
This is true as said in yups update 2 from above
angular2/core -> @angular/core
angular2/compiler -> @angular/compiler
angular2/common -> @angular/common
angular2/platform/common -> @angular/common
angular2/common_dom -> @angular/common
angular2/platform/browser -> @angular/platform-browser-dynamic
angular2/platform/server -> @angular/platform-server
angular2/testing -> @angular/core/testing
angular2/upgrade -> @angular/upgrade
angular2/http -> @angular/http
angular2/router -> @angular/router
angular2/platform/testing/browser -> @angular/platform-browser-dynamic/testing
You are trying to access Component from wrong/old directory of node_modules. Please access Component from
import { Component, OnInit } from '@angular/core';
instead of : import { Component, View } from 'angular2/angular2';
AND
Access bootstrap from bellow path :
import { bootstrap } from 'angular2/platform/browser';
import {Component} from "@angular/core";
@Component({
selector: "userForm",
template: '<div><input type="text" name="name" [disabled]="flag"/></div>'
});
export class userForm{
public flag = false; //boolean value: true/false
}
Second
import {Component} from "@angular/core";
import {FormBuilder } from "@angular/forms";
@Component({
selector: "login",
providers: [FormBuilder],
templateUrl: "/scripts/src/components/login/login.html"
})
export class login {
}
It changed module just ahead of going beta to
import {Component, View} from 'angular2/core';
FYI: bootstrap also changed to
import {bootstrap} from 'angular2/platform/browser';
as a result a lot of the blog posts on the net are out of date :-(