Sunday, December 1, 2019

Error: Cannot find control with name:

Hi Guys ,

In this blog I will share information related to error :

Error: Cannot find control with name:

The complete error log is as follows :


StatusComponent.html:2 ERROR Error: Cannot find control with name: 'sname'
    at _throwError (shared.ts:140)
    at setUpControl (shared.ts:36)
    at FormGroupDirective.addControl (form_group_directive.ts:132)
    at FormControlName._setUpControl (form_control_name.ts:278)
    at FormControlName.ngOnChanges (form_control_name.ts:207)
    at checkAndUpdateDirectiveInline (provider.ts:208)
    at checkAndUpdateNodeInline (view.ts:429)
    at checkAndUpdateNode (view.ts:389)
    at debugCheckAndUpdateNode (services.ts:431)
    at debugCheckDirectivesFn (services.ts:392)


You may get this error while using reactive Forms in Angular
Lets look at the code which caused this error .

import { Component, OnInit } from '@angular/core';
import { FormControl , FormGroup} from '@angular/forms';

@Component({
  selector: 'app-status',
  templateUrl: './status.component.html',
  styleUrls: ['./status.component.css']
})
export class StatusComponent implements OnInit {
  statusForm = new FormGroup(
    {
      fname : new FormControl('')
    }

  );
  
  constructor() { }

  ngOnInit() {
  }

  updateStatus() {
     
  }

}


<p>   {{statusForm.fname}} </p>
<form [formGroup]="statusForm">
<label>
  First Name 
  <input type="text"  formControlName="fname">
Second Name 
  <input type="text"  formControlName="sname">

</label>
 
</form>

You can see we have two form controls in the HTML but only one form control in Controller .



Lets fix this error . We need to add another FormControl to a FormGroup .

The working code is as below .

import { Component, OnInit } from '@angular/core';
import { FormControl , FormGroup} from '@angular/forms';

@Component({
  selector: 'app-status',
  templateUrl: './status.component.html',
  styleUrls: ['./status.component.css']
})
export class StatusComponent implements OnInit {
  statusForm = new FormGroup(
    {
      fname : new FormControl(''),
       sname : new FormControl('')
    }

  );
  
  constructor() { }

  ngOnInit() {
  }

  updateStatus() {
     
  }

}

Hope this helps . Thanks !

TypeError: Cannot convert undefined or null to object

Hi Guys ,

In this blog I will share information related to error :

TypeError: Cannot convert undefined or null to object.

The complete error log is as follows :

main.ts:13 TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at FormGroup._forEachChild (model.ts:1526)
    at FormGroup._setUpControls (model.ts:1531)
    at new FormGroup (model.ts:1258)
    at new StatusComponent (VM2760 status.component.ts:16)
    at createClass (provider.ts:268)
    at createDirectiveInstance (provider.ts:136)
    at createViewNodes (view.ts:303)
    at callViewAction (view.ts:636)
    at execComponentViewsAction (view.ts:559)
eval @ main.ts:13



You may get this error while using reactive Forms in Angular
Lets look at the code which caused this error .

statusForm = new FormGroup();


You can see the formGroup object is created without passing any parameter to it .

Lets fix this error . We need to add a FormControl to a FormGroup .

The working code is as below .

statusForm = new FormGroup(
    {
      fname : new FormControl('')
    }

  );


Hope this helps .Thanks!

Saturday, November 30, 2019

can't bind to 'formcontrol' since it isn't a known property of 'input'

Hi Guys ,

In this blog I will share information related to error :
can't bind to 'formcontrol' since it isn't a known property of 'input'.

The complete error log is as follows :

Error in /turbo_modules/@angular/compiler@8.0.0/bundles/compiler.umd.js (2479:21)
Template parse errors:
Can't bind to 'formControl' since it isn't a known property of 'input'. ("<label>
Name:
<input type="text" [ERROR ->][formControl]="status">
</label>"): ng:///AppModule/StatusComponent.html@2:21
No provider for NgControl ("<label>
Name:
[ERROR ->]<input type="text" [formControl]="status">
</label>"): ng:///AppModule/StatusComponent.html@2:2



You may get this error while using angular reactive forms .

To fix this error add RectiveFormsModule in the inports array .


@NgModule({
  imports:      [ BrowserModule, FormsModule ,ReactiveFormsModule ],
  declarations: [ AppComponent, HelloComponent, StatusComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }


Checkout the video on how to fix this error .



Hope this fixes the issue ! Thanks .

Sunday, November 24, 2019

JSX expressions must have one parent element.

Hi Guys ,


This blog is about the error " JSX expressions must have one parent element.

Let's look at the erroneous code .

import React from 'react';

export default ({ name }) => <h1>Hello {name}!</h1>

<input type="text" placeholder="enter asset"/>;


You can see there are two elements <h1> and <input> .
The error is because react does not allow multiple component as a parent component . To fix this issue we can put the two elements under single parent component , like a <div> .

Let's fix the code .

import React from 'react';

export default ({ name }) => <div><h1>Hello {name}!</h1>

<input type="text" placeholder="enter asset"/>  </div>;


The error is gone . Hope this helps , Thanks !



Checkout this error in youtube .


Let me know if you still face error in the comments below .

Saturday, October 19, 2019

ERROR in node_modules/firebase/index.d.ts(4336,38): error TS1005: ';' expected.

Hi Everyone ,

This blog is about the error " ERROR in node_modules/firebase/index.d.ts(4336,38): error TS1005: ';' expected."




I have faced this error while adding firebase to angular .
The solution is to update the typescript to version 3.1.3 .

add firebase to angular

Hi Everyone ,

This blog is about how we can add firebase to angular and access the database .

Install firebase and @angular/fire using npm .

npm i @angular/fire

npm i firebase

Create a file in src/environments/environment/ts


export const environment = {
  production: false,
  
  firebase:{
    apiKey: "your api key",
    authDomain: "test-15b0a.firebaseapp.com",
    databaseURL: "https://test-15b0a.firebaseio.com",
    projectId: "your project id ",
    storageBucket: "test-15b0a.appspot.com",
    messagingSenderId: "846752590782",
    appId: "1:846752590782:web:cdfb301f4daf4448"
  }
};


And then , add firebase to app.module.ts


Next step is to access it via service


Hope this helps . Thanks !

Friday, October 18, 2019

Target container is not a DOM element.

Hi Guys ,


This blog is about the error " Target container is not a DOM element. " 



 The full error in the console log is as follows :

Invariant Violation: Target container is not a DOM element.
    at invariant (https://react-gartc9.stackblitz.io/turbo_modules/react-dom@16.8.0/cjs/react-dom.development.js:55:15)
    at Object.render (https://react-gartc9.stackblitz.io/turbo_modules/react-dom@16.8.0/cjs/react-dom.development.js:20611:36)
    at Object.eval (https://react-gartc9.stackblitz.io/~/index.js:43:13)
    at eval (https://react-gartc9.stackblitz.io/~/index.js:45:4)
    at eval (https://react-gartc9.stackblitz.io/~/index.js:46:3)
    at eval (<anonymous>)

Lets see the erroneous code .

HTML code

<div id="root"></div>

and javascript :


render(<App />, document.getElementById('app'));

To fix this update the render function and specify the id of the HTML element . The working code is as follows :


render(<App />, document.getElementById('root'));



Hops this helps .
Thanks !


Thursday, October 17, 2019

Error response from daemon: No such container:docker

Hi Guys ,

This blog is about the issue "Error response from daemon: No such container:"
I got this error while using docker , I had an docker container which I tried to stop using the command

docker stop myContainer

But instead of stopping it docker gave an error message like
Error response from daemon: No such container:myContainer .

Later I have found out that the docker container name was incorrect .

So I did docker ps

And I got the list of docker containers .
I checked the name of the container which needs to be stopped under the names column . I am able to stop the container .



The second situation where I got the same error is when I tried to start the docker container using the command
start docker myContainer .
Same as above the name is wrong , hence the error .

Watch the video for more details .

Sunday, October 13, 2019

Unexpected value '[object Object]' declared by the module 'AppModule'

Hi Guys ,

This blog is about the error " Unexpected value '[object Object]' declared by the module 'AppModule'" .

Error in the page :

Error in /turbo_modules/@angular/compiler@8.2.10/bundles/compiler.umd.js (2603:21)
Unexpected value '[object Object]' declared by the module 'AppModule'

Error in the console :


Error: Unexpected value '[object Object]' declared by the module 'AppModule'
at syntaxError (util.ts:100)
    at eval (metadata_resolver.ts:603)
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.getNgModuleMetadata (metadata_resolver.ts:600)
    at JitCompiler._loadModules (compiler.ts:127)
    at JitCompiler._compileModuleAndComponents (compiler.ts:107)
    at JitCompiler.compileModuleAsync (compiler.ts:61)
    at CompilerImpl.compileModuleAsync (compiler_factory.ts:58)
    at compileNgModuleFactory__PRE_R3__ (application_ref.ts:50)
    at PlatformRef.bootstrapModule (application_ref.ts:307)


We faced this error due while updating declarations in app.module.ts .

Lets see the erroneous code .

@NgModule({
  imports:      [ BrowserModule, FormsModule ,  AngularFireModule.initializeApp(environment.firebase)],
  declarations: [ AppComponent,
  AngularFireModule.initializeApp(environment.firebase),
   HelloComponent, SubjectComponent ],
  bootstrap:    [ AppComponent ],
  providers: [QuizService , AngularFirestore]
}) 


check the declarations part regarding the issue , remove    AngularFireModule.initializeApp(environment.firebase),th e from declarations .

Working code :


@NgModule({
  imports:      [ BrowserModule, FormsModule ,  AngularFireModule.initializeApp(environment.firebase)],
  declarations: [ AppComponent,
  
   HelloComponent, SubjectComponent ],
  bootstrap:    [ AppComponent ],
  providers: [QuizService , AngularFirestore]
})

Hope this helps . Thanks ! .

Monday, October 7, 2019

Errors while compiling. Reload prevented.

Hi Guys ,

This blog is about the error Errors while compiling. Reload prevented.

I have faced this error while running an angular project . I used ng serve to run the project . Whenever we make changes to the code , angular compiles and auto reloads the app .

So while compiling if there are multiple error it will stop the load and as a developer you need to look into your code and find out root cause of all the errors .It could be a recent line of code you changed .


Module not found: Error: Can't resolve '@angular/cdk/a11y'

Hi Guys ,

This blog is about the error Module not found: Error: Can't resolve '@angular/cdk/a11y' .

The full error is as follows :

/src/app/material-module.ts Module not found: Error: Can't resolve '@angular/cdk/a11y' in ..


This error is due to the material module is missing but the code is expecting it to be in the node_modules .

To fix this issue simply type the following command in the command prompt .

npm install --save @angular/material

If this does not work remove the node_modules and perform npm update .


Thanks !

Sunday, October 6, 2019

Could not find module "@angular-devkit/build-angular"

Hi Guys ,

This blog is about the issue Could not find module "@angular-devkit/build-angular" . This error comes when you run the command ng serve .

The complete error log is as follows :


Could not find module "@angular-devkit/build-angular" from "F:\\progvocab\\study\\gitRepo\\new\\qanda".
Error: Could not find module "@angular-devkit/build-angular" from "F:\\progvocab\\study\\gitRepo\\new\\qanda".
    at Object.resolve (C:\Users\progvocab\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\core\node\resolve.js:141:11)
    at Observable.rxjs_1.Observable [as _subscribe] (C:\Users\progvocab\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\architect\src\architect.js:132:40)
    at Observable._trySubscribe (C:\Users\progvocab\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:43:25)
    at Observable.subscribe (C:\Users\progvocab\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:29:22)
    at DoOperator.call (C:\Users\progvocab\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\operators\tap.js:29:23)
    at Observable.subscribe (C:\Users\progvocab\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:24:22)
    at C:\Users\progvocab\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\util\subscribeTo.js:22:31
    at Object.subscribeToResult (C:\Users\progvocab\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\util\subscribeToResult.js:7:45)
    at MergeMapSubscriber._innerSub (C:\Users\progvocab\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:75:38)
    at MergeMapSubscriber._tryNext (C:\Users\progvocab\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:72:14)

Now , this error comes if the dev dependency is missing angular devkit .
So in the command prompt type the following command to install angular devkit

npm install --save-dev @angular-devkit/build-angular

Hope this helps in resolving the issue you faced .

Saturday, October 5, 2019

Error: Attempting to open an undefined instance of `mat-autocomplete`

Hi Guys ,

In this blog I will share information related to error :
Error: Attempting to open an undefined instance of `mat-autocomplete`

You may find this error when you use autocomplete in angular material .

The full error log is as follows :

AutocompleteSimpleExample.html:3 ERROR Error: Attempting to open an undefined instance of `mat-autocomplete`. Make sure that the id passed to the `matAutocomplete` is correct and that you're attempting to open it after the ngAfterContentInit hook.
    at getMatAutocompleteMissingPanelError (autocomplete-trigger.ts:99)
    at MatAutocompleteTrigger._attachOverlay (autocomplete-trigger.ts:615)
    at MatAutocompleteTrigger._handleFocus (autocomplete-trigger.ts:458)
    at Object.eval [as handleEvent] (VM548 AutocompleteSimpleExample.ngfactory.js:114)
    at handleEvent (view.ts:138)
    at callWithDebugContext (services.ts:630)
    at Object.debugHandleEvent [as handleEvent] (services.ts:377)
    at dispatchEvent (util.ts:135)
    at eval (element.ts:200)
    at HTMLInputElement.eval (dom_renderer.ts:52)

Lets look at the code which is causing this issue .

<form class="example-form">
  <mat-form-field class="example-full-width">
    <input type="text" placeholder="Pick one" aria-label="Number" 
    matInput [formControl]="myControl" [matAutocomplete]="matAutocomplete">
    <mat-autocomplete #auto="matAutocomplete">
      <mat-option *ngFor="let option of options" [value]="option">
        {{option}}
      </mat-option>
    </mat-autocomplete>
  </mat-form-field>
</form>


You can see we have a mat-autocomplete  with a template reference variable #auto and the value as matAutocomplete. Also notice that property binding [matAutocomplete] is having value as mat

Now the error is due to we are using the value of the template reference variable instead of the reference .

Lets correct the code .

<form class="example-form">
  <mat-form-field class="example-full-width">
    <input type="text" placeholder="Pick one" aria-label="Number" 
    matInput [formControl]="myControl" [matAutocomplete]="auto">
    <mat-autocomplete #auto="matAutocomplete">
      <mat-option *ngFor="let option of options" [value]="option">
        {{option}}
      </mat-option>
    </mat-autocomplete>
  </mat-form-field>
</form>

Hope this fixes the issue you are facing .

Friday, October 4, 2019

Deploy Microservice to AWS

Hi Guys ,

This blog will have a brief information on how to deploy a micro service in AWS .

So first thing is you need an AWS account , which will provide different services to achieve the same .
Login to AWS management console .

In this example I will take spring boot micro service as a reference .

You need to create an EC2 instance where we are going to run the micros service .

using maven build the jar file Spring boot and upload to AWS S3 .
Create  a bucket in S3 , and then upload the jar file .
Make sure you give the access as public so that it can be downloaded to the EC2 from S3 .




Sunday, September 22, 2019

Saturday, September 7, 2019

Component template should contain exactly one root element.

Hi Guys ,

In this blog I will share information related to error : Component template should contain exactly one root element.

This error is related to template attribute .




Let us see the erroneous code .

template: `
<h1>My data </h1>
<table>
<th>
<td>
Stock Name
</td>
<td>
Market Capitalization
</td>
</th>
<tr v-for = "a in stocks">
<td >
{{a.name}}
</td>
<td>
{{a.mCap}}
</td>
</tr>
</table>
` ,

You can notice that the template attribute starts with an h1 tag and then has a table tag . But in vue js the component template should have only one root element , so you have to enclose the entire component in one tag . To fix this I have removed the h1 tag.

template: `
<table>
<th>
<td>
Stock Name
</td>
<td>
Market Capitalization
</td>
</th>
<tr v-for = "a in stocks">
<td >
{{a.name}}
</td>
<td>
{{a.mCap}}
</td>
</tr>
</table>
` ,



Hope this resolves the issue . Thanks !


Youtube link :


The full error details is as below  :

[Vue warn]: Error compiling template:


  <h1>My data </h1>
    <table>
      <th>
        <td>
          Stock Name
        </td>
        <td>
          Market Capitalization
        </td>
      </th>
      <tr v-for = "a in stocks">
        <td  >
          {{a.name}}
        </td>
        <td>
          {{a.mCap}}
        </td>
      </tr>
    </table>
  

- Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.


found in

---> <ByMarketCap>
       <Anonymous>
         <Root>

The "data" option should be a function that returns a per-instance value in component definitions.

Hi Guys ,

In this blog I will share information related to error : The "data" option should be a function that returns a per-instance value in component definitions.

This error is related to data attribute .

Let us see the erroneous code .

` ,
data : {
stocks : [
{"name" : "HDFC" , "mCap": "1000Cr"} ,
{"name" : "ICICI" , "mCap": "100Cr"}
]
}
}

The error is due to Vue expects the data attribute to contain a function .
Let us fix this by wrapping our data in a function .

` ,
data: function () {
return {
stocks: [
{ "name": "HDFC", "mCap": "1000Cr" },
{ "name": "ICICI", "mCap": "100Cr" }
]
}
}


Hope this resolves the issue . Thanks !
Youtube link below :





Friday, July 12, 2019

Linux important commands

sudo :
Switch to super user
sudo su
chmod :



ssh : protocol to log into remote system.

grep : Global Regular Expression Print

nohup :
example : run java without holding the current session.

nohup java -jar a.jar &




Tuesday, July 2, 2019

ReferenceError: MongoClient is not defined

Hi Guys ,

In this blog I will share information related to error : ReferenceError: MongoClient is not defined .


This error is related to the node.js code which is trying to connect to the database . To fix this check the following lines of code highlighted in yellow  . You need to make sure module mongodb is imported and the MongoClient is referenced using the variable .






var mongo = require('mongodb');
var url = "mongodb://localhost:27017/qanda";
mongo.MongoClient.connect(url, function(err, db) {
if (err) throw err;
console.log("Database created!");
db.close();
});
Please make changes to the code and retest . Hope this will help you in resolving this issue .

MongoNetworkError: failed to connect to server MongoNetworkError: connect ECONNREFUSED


Hi Guys ,

You might have faced an error like MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]

We generally face this error when the database server is down , if you bring the database server up you will not face this error .

The full error is as follows :


(node:15564) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
F:\\study\nodejs\node_modules\mongodb\lib\topologies\server.js:240
            throw err;
            ^

MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
    at Pool.<anonymous> (F:\\study\nodejs\node_modules\mongodb-core\lib\topologies\server.js:431:11)
    at emitOne (events.js:116:13)
    at Pool.emit (events.js:211:7)
    at connect (F:\\study\nodejs\node_modules\mongodb-core\lib\connection\pool.js:557:14)
    at makeConnection (F:\\study\nodejs\node_modules\mongodb-core\lib\connection\connect.js:39:11)
    at callback (F:\\study\nodejs\node_modules\mongodb-core\lib\connection\connect.js:261:5)
    at Socket.err (F:\\study\nodejs\node_modules\mongodb-core\lib\connection\connect.js:286:7)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)


The code snipped to connect to mongo db is as follows :


var mongo = require('mongodb');
var url = "mongodb://localhost:27017/qanda";
mongo.MongoClient.connect(url, function(err, db) {
if (err) throw err;
console.log("Database created!");
db.close();
});


Sunday, June 9, 2019

Groovy Interview Questions

Important Interview Question in Groovy .


  • Compare Java with Apache Groovy 


  1. Groovy is a scripting language 
  2. Less syntax
  3. default access modifier is public 
  4. automatic getters and setters
  5. does not support ARM introduced in java 7
  6. allows variable substitution inside double quotes 
  7. does not support anonymous inner class , lambda , use closure instead .
  8. groovy supports operator overloading 

  • What is AST transformations.
 the ability to customize the Abstract Syntax Tree representing your programs before the compiler walks this tree to generate Java bytecode .
  • Explain closure in groovy
A closure in Groovy is an open, anonymous, block of code that can take arguments, return a value and be assigned to a variable

{ [closureParameters -> ] statements }

  • Explain GRAPE 
Grape stands for the Groovy Adaptable (Advanced) Packaging Engine
Grape helps you download and cache external dependencies from within your script with a set of simple annotations.

@Grab('org.apache.httpcomponents:httpclient:4.2.1')

  • What is the use of @GrabResolver 
By default GRAPE uses Maven Central Repository , if we need to add our own repository we can use  @GrabResolver  .





Friday, May 17, 2019

Java Architect interview questions


  • What are the 4 architecture domain TOGAF deal with ?
  1. business
  2. data
  3. application 
  4. technology


  • What is TOGAF ADM ?
Architecture Development Method .
It provides a tested and repeatable process for developing architectures .


  • What are the phases within the ADM .
  1. preliminary
  2. architecture vision
  3. business architecture
  4. information system architecture
  5. technology architecture
  6. opportunities and solution
  7. migration planning
  8. implementation governance
  9. architecture change management
  10. requirement management 
  • What are the SOLID principles?


  • Explain encryption in Java

Create key object using secret key spec passing key and algorithm
Cipher.getinstance blowfish
Set mode encrypt / decrypt
Cipher.dofinal//encrypted
Base64.encode // encoded



  • A method is defined with return type string , I do not want to return anything but still want the method to compile , how can I achieve that ?
instead of return string we can throw an Exception


  • How to access private variables of a class ?
through Reflection API Field.setAccessible(true);





Saturday, April 27, 2019

Design Patterns Interview Questions


  • Explain GoF Design patterns .
  1. Creational : defines  how the objects are created 
  2. Structural : defines relationship between the classes
  3. Behavioral : defines how objects communicate with each other 
  • Explain Creational Design Patterns .
  1. Factory
  2. Abstract Factory
  3. Builder
  4. Singleton
  5. Prototype
  • Explain Structural Design Pattern .
  1. Adapter : implementing class can work with incompatible interface.
  2. Bridge : enables to implementing class and the interface to vary independently.
  3. Composite : Composite lets client treat individual objects and compositions of objects uniformly.
  4. Decorator
  5. Facade
  6. Flywheel
  7. Proxy : a new object created to handle the operation.
  • Explain Behavioral Design Pattern .
  1. Chain of Responsibility
  2. Command
  3. Interpretor : how to include language  elements
  4. Iterator
  5. Mediator : simplify communication between objects
  6. Observer : multiple objects notification
  7. State : modify the behavior on state change
  8. Template : abstract definition of algorithm
  9. Visitor : add polymorphic functions to class noninvasively .
  • Explain J2EE Patterns 

  • Explain association in Java .
Association : has a relationship 
  1. Composition : sub objects cannot exist without the parent object .
  2. Aggregation : sub objects can exist without the parent object .

  • Explain UML class diagram .

Tuesday, April 23, 2019

Node js interview questions


This blog is just for revision .


  • Explain the version of a package in node js 
  1. major
  2. minor
  3. patch
  4. pre major
  5. pre minor
  6. pre patch
  7. pre release
  • What is the use of ~ and ^
  1. ~ matches the most recent patch version for the minor version
  2.  ^ matches the most recent minor version of the major version     

  • What are modules

Modules are way of organising reusable components


  1. Core
  2. Local
  3. Third party



  • What is the use of require()


It is used to import core modules.It is a function that can be used to import symbols from another module to the current scope



  • What is commonjs

Commonjs defines standards for modules, packages and unit testing.



  • What is AMD ?

Asynchronous


  • Explain the parts of package.json
  1. name
  2. version
  3. license
  4. description

  • Explain async functions
  • Explain await

Friday, April 19, 2019

mat-form-field must contain a MatFormFieldControl.


Hi Guys ,



Today I have faced this error :

ERROR Error: mat-form-field must contain a MatFormFieldControl.

Later I have found out that I have missed to add the attribute matInput .

<mat-form-field>
<input type="text" name="name" ngModel #refName="ngModel" name="name" required >
</mat-form-field>

Once I added the attribute to the input field matInput , the error was resolved .

<mat-form-field>
<input matInput type="text" name="name" ngModel #refName="ngModel" name="name" required >
</mat-form-field>


Video Link :

Full stack trace is as below .

CustDetailComponent.html:4 ERROR Error: mat-form-field must contain a MatFormFieldControl.
    at getMatFormFieldMissingControlError (form-field.es5.js:119)
    at MatFormField.push../node_modules/@angular/material/esm5/form-field.es5.js.MatFormField._validateControlChild (form-field.es5.js:771)
    at MatFormField.push../node_modules/@angular/material/esm5/form-field.es5.js.MatFormField.ngAfterContentInit (form-field.es5.js:453)
    at callProviderLifecycles (core.js:9553)
    at callElementProvidersLifecycles (core.js:9534)
    at callLifecycleHooksChildrenFirst (core.js:9524)
    at checkAndUpdateView (core.js:10455)
    at callViewAction (core.js:10692)
    at execComponentViewsAction (core.js:10634)
    at checkAndUpdateView (core.js:10457)

ec2-user@ec2 Permission denied