Angular is a development platform for building mobile and desktop web applications. It provides a way to build apps for any deployment target by reusing existing code. Using HTML as the template language, Angular offers developers the possiblity to create their own components.
Note: Make sure that you are running on the latest Node.js and npm versions.
Steps:
The root folder contains a few configuration files and the app folder which holds the main content of the application.
/root
/app
/index.html
/src
/app.component.ts
/app.module.ts
/main.ts
/assets
/package.json
/tsconfig.json
/tsconfig.aot.json
/webpack.config.js
Note: Structure may vary based on your application needs.
Apart from the package.json and tsconfig.json you will need tsconfig.aot.json and webpack.config.js files.
The tsconfig.aot.json is a normal tsconfig.json file, but with AoT-oriented settings.
Let's take a look at the config files:
package.json
When we type npm start in our CLI it executes both the commands. We just need to include the bundled file in or HTML and run it.
Here we have also added a watch command, which executes start on every save we make in a .ts/.css/htm file.
tsconfig.json
tsconfig.aot.json
What's really new is the ngc section called angularCompilerOptions. Here we say to the compiler to skip generating metadata files. We have also set genDir which means all of our recompiled files will go in that folder. For more information about AOT please refer to the official Ahead-Of-Time Compilation CookBook.
webpack.config.js
For more information about Webpack please refer to the official guide.
Add the needed references and the <app-root></app-root> tag to the body of index.html.
That's the tag where we initialize the main component.
Then import the bundled file we received after running the npm start command.
Imports:
@Component decorator:
The Class:
In the above example we create the widget through attributes.
There is another way through method called createComponent. It takes just one argument - an object containing the settings for the widget.
Event Names in the Angular Components are the same as the Event Names in the Javascript Widgets.
The only thing you need to do is to put "on"
before the Javascript widget event name and upperCase it's first letter.
Every widget also have a method setOptions which accepts an object as an argument. This object contains widget settings.
We often want to both display a data property and update that property when the user makes changes.
Let's take a look at the following example:
If you are using any of the Input based widgets like jqxInput, jqxComplexInput, jqxDateTimeInput and so on you must import the FormsModule in your app.module.ts file and add it to the @NgModel imports: