I'm trying to define a scope variable in Angular 2. Here is the code:
export class GroceryComponent {
task = {
name: ''
};
tasks = [];
}
But its throwing the following error :
Type String is not assignable to type '{ name : string; }'
Probably other parts of your code try to change the task property from the instance of GroceryComponent
Something similar with this error:
class GroceryComponent {
task = {
name : ""
};
tasks = [];
};
let product = new GroceryComponent();
product.task = 55; // ERROR MESSAGE: Type '55' is not assignable to type '{ name: string; }'.
Interactive example on: TypeScript Playground
task? So many questions