I followed Zach's Answer and create new VS 2015 .NET 5 project and run Angular 2 with Typescript. It looks like its working. But there is a little problem:
MyApp.ts :
import { Component } from "angular2/core";
@Component({
selector: "my-app",
template: `
<div>Hello from Angular 2</div>
`
})
export class MyApp {
public constructor() {
}
}
When i change the template, type some different text, lets say <div>Some text here</div>
, and then i recompile the project and run in browser to see the change - it still shows the older template text - Hello from Angular 2. So i checked in the MyApp.js
(compiled from the MyApp.ts
), and there is no change also.
(I tried building the project multiple times, also close VS and reopen it - MyApp.ts
is compiled only once - the first time when its created.)
Additional files: (that may help solving)
tsconfig.json :
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules"
]
}
Where it comes from (the problem)? Angular? Typescript? VS 2015? From my opinion - must be something with Typescript and its compilation? Any suggestions?
P.S: this implementation do not work on IE!
Progress: if i clean - rebuild - build my project - it compiles the .ts files, but its the same thing as the first time compilation - not actually a solution...
Angular 2 Template for Visual Studio 2015 with update 3
Steps:-
If you want to manually install all the packages
npm install
Note: Please install all the Updates from visual studio 2015 related to VS2015 update 3 and "DotNetCore.1.0.0.RC2-VS2015Tools.Preview1". Then only you will be able to run this Solution.
You can download "Angular2 Template for Visual Studio 2015 with update 3" from here...
https://github.com/narottamgoyal/Vs2015Angular2Template.git
I'm working in visual studio with a tsconfig file. For me, it works after add "compileOnSave" attribute, my tsconfig looks like this:
In visual studio, go to options-> typescript-> project-> enable the checkbox "Automatically compile typescript files that are not a part of project"
And the radio field "Use AMD code generation for modules that are not part of the project".
This should generate new Js for you.
There is a similar thread here. Please check, Type Script is not generating JavaScript in my Visual Studio Community edition 2015