On the same folder where you will download 'app.js', do these things
npm init -y
npm install --save express cors
npm install -g nodemon
# update brew because `brew update` is broken after updating to El Capitan | |
cd `brew --prefix` | |
git fetch origin | |
git reset --hard origin/master | |
sudo shutdown -r now # restart the computer | |
# open terminal and run the following | |
brew update | |
brew cleanup |
On the root module (app.module.ts)
On the app.service.ts
In angular.json
<h1>{{ title }}</h1> | |
<button (click)="subscribe()"> | |
Subscribe | |
</button> |
To create the project | |
ng new parentchild | |
ng g c childone | |
cd parentchild | |
npm install --save bootstrap |
<h1>{{ title }}</h1> | |
<strong>Can you guess a number betwee 1 to 100?</strong> | |
<p> | |
<input placeholder="type an integer" [(ngModel)]="guess"> | |
</p> | |
<button (click)="guessTheNumber()"> | |
Guess the number | |
</button> | |
<p></p> |
class MainActivity : AppCompatActivity() { | |
val Log = Logger.getLogger(MainActivity::class.java.name) | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
} | |
override fun onCreateOptionsMenu(menu: Menu?): Boolean { | |
Log.info("onCreateOptionsMenu") |
// Warning, this code won't compile in Kotlin | |
// it has problemss. Can you spot which line won't compile? | |
fun main(args: Array<String>) { | |
val mlist = listOf(Programmer("Ted"), Tester("Steph")) // (1) | |
val mprogs = mlist.typeOf<Programmer>() // (2) | |
mprogs.forEach { // (3) | |
println("${it.toString()} : ${it.javaClass.simpleName}") | |
} |
Let’s deal with the meaning of reify first. It means to make something real, and the reason we’re using reify and generics on the same statement is because of Java’s type erasure.
Type erasure means exactly what you think it means. Java, and Kotlin as well, erases generic type information at runtime. There are good reasons for this, but unfortunately, we’re not going to discuss those reasons why the language design is like that — but we will discuss its effects. Because of type erasure, you can’t perform any reflection activity and you can’t do any runtime check on a type. So, the following code won't work.
fun checkInfo(items:List<Any>) {
if(items is List<String>) { // (1)
println("item is a list of Strings")
}
}