Angular Material Component schematics

156 Views Asked by At

Whenever I run this command ng generate @angular/material:navigation dashboard the terminal shows this

The 'path' option in '__\Desktop\machine test\employee\node_modules@angular\material\schematics\ng-generate\navigation\schema.json' is using deprecated behaviour. 'workingDirectory' smart default provider should be used instead.(0 , validation_1.validateName) is not a function

Is there another way to implement schematics in my project...:)

I tried this:

"$default": {
  "$source": "projectName"
}

in path of schema.json

Deprecated behavior problem solved but the 'validation is not a function' still remains.

1

There are 1 best solutions below

0
On

I'm making an assumption that the version of @angular-devkit/schematics-cli you're using is a newer version than the version of @angular/materials you're using, which is why you're seeing this message.


Previously when defining the "path" property in a schematic you would do the following in the schema.json for the schematic definition:

{
  ...
  "properties": {
    "path": {
      "type": "string",
      "format": "path",
      "description": "The path at which to create .README directory and files",
      "visible": false
    }
  }
}

When the schematic was run if no "path" arg was supplied a default would be correctly set.

This can be seen in the 13.0.x version the the angular material dashboard schematic


As the error suggests (although unless you know schematics it's admittedly not very helpful) the "path" definition needed to be updated to:

{
  ...
  "properties": {
    "path": {
      "type": "string",
      "format": "path",
      "description": "The path at which to create .README directory and files",
      "visible": false,
      "$default": {
        "$source": "workingDirectory"
      }
    }
  }
}

As can be seen in the 14.0.x version the the angular material dashboard schematic


"workingDirectory" as the error suggests is a 'smart default provider' that sets the default value of the path.

"projectName" is also a 'smart default provider' but it sets the default value as the project name, not the current path.