6

declared loginObj in login.component.ts as below

 public loginObj: Object = {
   email:'',
   password:''
 };
 public registerObj: Object = {
  email:'',
  name:'',
  password:''
 };

HTML

<input placeholder="" type="text"  [(ngModel)]="loginObj.email" autofocus="true" required>
<input placeholder="" type="text"  [(ngModel)]="loginObj.password" autofocus="true" required>
  • Replace `: Object` with `: any`. –  Mar 20 '18 at 13:06
  • you might find this answer helpful to explain why you cannot use `Object` in this way https://stackoverflow.com/questions/18961203/typescript-any-vs-object#28795689 use `object` or as answered below, create an interface with a unique name – krantzinator Mar 20 '18 at 13:08

4 Answers4

6

The error is right this property is not existing. You need to create interface

export interface LoginObject {
   email:string;
   password:string;
}

adn then import it into your component and declare your object like this

public loginObj: LoginObject = {
   email:'',
   password:''
 };

You can even try to declare it just like this

public loginObj: LoginObject;

and it will work for you

Kraken
  • 1,905
  • 12
  • 22
5

Make the type any instead of Object or define an interface and make it the type.

0

I got a similar error while building it in jenkins. The following command resolved the issue:

npm install
npm run ng build --prod

Hope it helps

www.admiraalit.nl
  • 5,768
  • 1
  • 17
  • 32
  • 1
    I believe this build command is not doing a production build and is acting as if you are running 'ng build' which still loads all the dev dependencies. – Rob DePietro Jan 30 '20 at 20:02
  • @RobDePietro I think you might be right. I ran this command in GCP cloud build and sure enough I was always getting the "Angular is running in development mode" console message. – Han K Jun 25 '20 at 19:20
0

try add this dependencies in your package.json "@angular/compiler-cli":"9.0.0 (or other version you used)"

danfox
  • 54
  • 2