2

I'm trying the heros tutorial from the angular 2 official site:

https://angular.io/docs/ts/latest/tutorial/toh-pt1.html

But I can't retrieve the values for AppComponent, it always returns an empty value.

Here the code of app.component.ts

import { Component } from '@angular/core';
@Component({
  selector: 'my-app',
  template: '<h1>Titulo: {{titulo}}</h1>'
})
export class AppComponent { 
    titulo: 'Tour de heroes';
}

When I save the changes and refresh the page I only get: Titulo:

1 Answer 1

2

It should be titulo = 'Tour de heroes', not titulo: 'Tour de heroes'.

: is used to assign type to variable, = is used to assign value to variable. Example:

titulo: string = 'Tour de heroes'

The code above declares variable titulo of type string and assigns value Tour de heroes to it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.