### Install ng-devui and optional dependencies
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Install the ng-devui package via npm and optionally install the DevUI design icon library for enhanced icon support in components.
```bash
npm i ng-devui
# Optional. Font icon library
# npm i @devui-design/icons
```
--------------------------------
### Shell Script Example (Basic Command)
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
A simple shell script demonstrating a basic command. Shell scripts are used for automating tasks in Unix-like operating systems. This example might execute a common command like `ls` or `echo`.
```bash
#!/bin/bash
# This is a comment
echo "Hello from shell script!"
ls -l
```
--------------------------------
### Java Method Example
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Demonstrates a Java method that performs a specific task. Methods define the actions that objects can perform. This example shows a method that adds two integers and returns the result.
```java
public class Calculator {
public int add(int a, int b) {
return a + b;
}
}
```
--------------------------------
### C# Method Example
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Shows a C# method that performs a calculation. Methods encapsulate executable code within a class. This example defines a method to add two integers.
```csharp
public class Calculator
{
public int Add(int a, int b)
{
return a + b;
}
}
```
--------------------------------
### Service Injection and Usage
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
This code example demonstrates how services are injected into components or other services in the ng-devui project. It highlights dependency injection patterns for sharing logic and data across the application.
```typescript
import { Injectable } from '@angular/core';
@Injectable({ providedIn: 'root' })
export class DataService {
getData(): string[] {
return ['Item 1', 'Item 2', 'Item 3'];
}
}
// In another component:
import { Component } from '@angular/core';
import { DataService } from './data.service';
@Component({
selector: 'app-data-consumer',
template: '
{{item}}
'
})
export class DataConsumerComponent {
items: string[];
constructor(private dataService: DataService) {
this.items = this.dataService.getData();
}
}
```
--------------------------------
### Basic Button Example (Angular)
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Demonstrates the implementation of a basic button component using DevUI's Angular library. This includes the necessary template markup and component logic for rendering a functional button.
```html
Click Me
```
```typescript
import { Component } from '@angular/core';
@Component({
selector: 'app-button-example',
templateUrl: './button-example.component.html'
})
export class ButtonExampleComponent {}
```
--------------------------------
### Fetch API Usage in JavaScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Shows how to use the Fetch API in JavaScript to make network requests. The Fetch API provides a modern and flexible way to handle HTTP requests, replacing the older XMLHttpRequest. This example demonstrates a GET request.
```javascript
fetch('/api/data')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
```
--------------------------------
### Shell Script Example (If Statement)
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Illustrates an `if` statement in a shell script. Conditional statements allow scripts to make decisions and execute different commands based on certain conditions. This example checks if a file exists.
```bash
#!/bin/bash
if [ -f "myfile.txt" ]; then
echo "myfile.txt exists."
else
echo "myfile.txt does not exist."
fi
```
--------------------------------
### Untitled
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
No description
--------------------------------
### Angular Service Example in TypeScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Presents a typical Angular service implementation in TypeScript. Services are used for business logic, data fetching, and sharing data between components. This example likely includes dependency injection and common service patterns.
```typescript
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class DataService {
constructor(private http: HttpClient) { }
getData(): Observable {
return this.http.get('/api/data');
}
}
```
--------------------------------
### Install and Setup DevUI Angular Library
Source: https://context7.com/devcloudfe/ng-devui/llms.txt
Steps to install the DevUI library and its optional icon library using npm. Includes creating a new Angular project and adding DevUI to project styles.
```bash
# Create new Angular project
ng new my-project
cd my-project
# Install DevUI
npm i ng-devui
# Optional: Install icon library
npm i @devui-design/icons
```
--------------------------------
### Angular Service: Data Fetching Example
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
An example of an Angular service designed for data fetching, likely using HttpClient. Services are typically used to encapsulate business logic and data access.
```typescript
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class DataService {
private apiUrl = '/api/data'; // Example API endpoint
constructor(private http: HttpClient) { }
getData(): Observable {
return this.http.get(this.apiUrl);
}
}
```
--------------------------------
### Modal Dialog Usage (Angular)
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Provides an example of how to trigger and manage a modal dialog using DevUI's modal service. This covers opening the modal and handling its lifecycle.
```html
Open Modal
```
```typescript
import { Component } from '@angular/core';
import { DialogService } from 'ng-devui';
import { MyModalComponent } from './my-modal.component';
@Component({
selector: 'app-modal-example',
templateUrl: './modal-example.component.html'
})
export class ModalExampleComponent {
constructor(private dialogService: DialogService) {}
openModal() {
this.dialogService.open(MyModalComponent, {
width: '300px',
height: '200px',
data: { message: 'Hello from parent!' }
});
}
}
```
--------------------------------
### Angular Pipe: Custom Formatting Example
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
An example of a custom Angular pipe used for transforming data in templates. Pipes are useful for formatting text, dates, currencies, etc.
```typescript
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'capitalize'
})
export class CapitalizePipe implements PipeTransform {
transform(value: string | null, args?: any): string {
if (!value) {
return '';
}
return value.charAt(0).toUpperCase() + value.slice(1);
}
}
```
--------------------------------
### Shell Script Example (Variable Assignment)
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Shows how to assign and use variables in a shell script. Variables are used to store data temporarily within a script. This example defines a variable and then uses it in an `echo` command.
```bash
#!/bin/bash
MY_VARIABLE="Some Value"
echo "The variable contains: $MY_VARIABLE"
```
--------------------------------
### Class with Constructor and Methods in TypeScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Demonstrates a TypeScript class with a constructor and methods. Classes are fundamental building blocks for object-oriented programming, encapsulating data and behavior. This example shows property initialization and method definition.
```typescript
class Product {
name: string;
price: number;
constructor(name: string, price: number) {
this.name = name;
this.price = price;
}
display(): void {
console.log(`${this.name} - $${this.price}`);
}
}
```
--------------------------------
### Implement a Simple Service in Angular
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Illustrates how to create and use a service in Angular for data sharing or business logic. Services are typically injected into components to provide reusable functionality. This example shows a basic service with a method to retrieve some data.
```typescript
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class DataService {
constructor() { }
getData(): string[] {
return ['Item 1', 'Item 2', 'Item 3'];
}
}
```
--------------------------------
### Create a Basic Angular Component
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Shows the fundamental structure of an Angular component, including the `@Component` decorator, template, and class. This snippet is useful for developers starting with Angular or needing a quick reference for component creation. It defines a selector, template URL, and styles.
```typescript
import { Component } from '@angular/core';
@Component({
selector: 'app-my-component',
templateUrl: './my-component.component.html',
styleUrls: ['./my-component.component.css']
})
export class MyComponentComponent {
title = 'My Awesome Component';
}
```
--------------------------------
### SQL Query Example (SELECT)
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Presents a basic SQL SELECT query. SQL (Structured Query Language) is used for managing and querying relational databases. This query retrieves specific columns from a table.
```sql
SELECT column1, column2
FROM your_table_name
WHERE condition;
```
--------------------------------
### Promise Example in JavaScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Illustrates the basic usage of Promises in JavaScript. Promises represent the eventual result of an asynchronous operation, allowing for cleaner handling of asynchronous code compared to callbacks. This example shows a simple Promise creation.
```javascript
const myPromise = new Promise((resolve, reject) => {
// Simulate an asynchronous operation
setTimeout(() => {
resolve('Operation successful!');
}, 1000);
});
myPromise.then(result => {
console.log(result);
}).catch(error => {
console.error(error);
});
```
--------------------------------
### SQL Query Example (INSERT)
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Demonstrates a basic SQL INSERT statement. This query is used to add new rows of data into a database table. It specifies the table and the values to be inserted.
```sql
INSERT INTO your_table_name (column1, column2)
VALUES (value1, value2);
```
--------------------------------
### Configuration Loading
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
This code demonstrates a mechanism for loading configuration settings, possibly from a JSON file or environment variables. This is crucial for customizing application behavior and integrating with different environments.
```typescript
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class ConfigService {
private configUrl = '/assets/config.json'; // Example URL
constructor(private http: HttpClient) { }
loadConfig(): Observable {
return this.http.get(this.configUrl);
}
}
```
--------------------------------
### Python List Manipulation
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Demonstrates common list manipulation techniques in Python. Lists are versatile mutable sequences. This example shows creating a list, appending an element, and accessing elements by index.
```python
my_list = [1, 2, 3]
my_list.append(4)
print(my_list[0]) # Output: 1
```
--------------------------------
### C# Class Definition
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Provides a basic C# class definition. Classes are the foundation of object-oriented programming in C#, defining the structure and behavior of objects. This example includes a constructor and a property.
```csharp
public class Person
{
public string Name { get; set; }
public Person(string name)
{
Name = name;
}
}
```
--------------------------------
### CSS Class Styling
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Shows how to apply CSS styling using a class selector. Classes allow you to apply styles to multiple elements that share a common characteristic. This example sets the font size for elements with the class 'highlight'.
```css
.highlight {
font-size: 1.2em;
}
```
--------------------------------
### Angular Directive: Attribute Directive Example
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Demonstrates a simple Angular attribute directive that can be applied to elements to modify their behavior or appearance. Directives are used to extend HTML functionality.
```typescript
import { Directive, ElementRef, HostListener } from '@angular/core';
@Directive({
selector: '[appHighlight]'
})
export class HighlightDirective {
constructor(private el: ElementRef) { }
@HostListener('mouseenter') onMouseEnter() {
this.highlight('yellow');
}
@HostListener('mouseleave') onMouseLeave() {
this.highlight(null);
}
private highlight(color: string | null) {
this.el.nativeElement.style.backgroundColor = color;
}
}
```
--------------------------------
### Basic Java Class Definition
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Presents a simple Java class definition. Classes are the blueprints for creating objects in Java, encapsulating data and behavior. This example includes a constructor and a method.
```java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
```
--------------------------------
### Python Function Definition
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Shows a basic Python function definition. Functions are reusable blocks of code that perform specific tasks. This example defines a function that greets a person by name.
```python
def greet(name):
return f'Hello, {name}!'
print(greet('Python'))
```
--------------------------------
### Python Dictionary Usage
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Illustrates the use of dictionaries in Python. Dictionaries are mutable, unordered collections of key-value pairs. This example shows creating a dictionary, accessing values by key, and adding a new entry.
```python
my_dict = {'name': 'Alice', 'age': 25}
print(my_dict['name']) # Output: Alice
my_dict['city'] = 'New York'
print(my_dict)
```
--------------------------------
### Java Variable Declaration
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Illustrates variable declaration and initialization in Java. Variables are used to store data. This example shows integer and string variable declarations.
```java
public class Variables {
public static void main(String[] args) {
int count = 10;
String message = "Java Variables";
System.out.println(message + ": " + count);
}
}
```
--------------------------------
### Callback Function Example in JavaScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Demonstrates the use of callback functions in JavaScript. Callbacks are functions passed as arguments to other functions, to be executed later. This is a common pattern for handling asynchronous operations or event-driven programming.
```javascript
function greet(name, callback) {
console.log('Hello ' + name);
callback();
}
greet('World', function() {
console.log('Callback executed.');
});
```
--------------------------------
### HTML Button Element
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Shows the basic structure of an HTML button element. Buttons are interactive elements used to trigger actions on a web page. This example includes text content for the button.
```html
```
--------------------------------
### Input Field with Validation (Angular)
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Shows how to integrate input fields with validation rules using DevUI's Angular components. This example covers handling user input and displaying validation messages.
```html
Name
Name is required.
```
```typescript
import { Component } from '@angular/core';
@Component({
selector: 'app-input-validation',
templateUrl: './input-validation.component.html'
})
export class InputValidationComponent {
name: string = '';
}
```
--------------------------------
### Component Rendering and Lifecycle
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
This code demonstrates how components are rendered and managed within the ng-devui framework, focusing on lifecycle hooks. It illustrates the typical flow of component initialization, update, and destruction.
```typescript
import { Component, OnInit, OnDestroy } from '@angular/core';
@Component({
selector: 'app-example-component',
templateUrl: './example-component.html',
styleUrls: ['./example-component.scss']
})
export class ExampleComponent implements OnInit, OnDestroy {
constructor() { }
ngOnInit(): void {
console.log('Component initialized');
}
ngOnDestroy(): void {
console.log('Component destroyed');
}
}
```
--------------------------------
### Define a simple Express.js route for handling GET requests
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
This snippet illustrates how to define a basic GET route in an Express.js application. It sets up a listener for requests to the root path ('/') and sends a JSON response. This is fundamental for building web APIs with Node.js and Express.
```javascript
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.json({ message: 'Hello from the Express.js server!' });
});
app.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`);
});
```
--------------------------------
### Arrow Function Example in JavaScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Demonstrates the use of arrow functions in JavaScript. Arrow functions provide a shorter syntax for writing function expressions and have different behavior regarding the `this` keyword. This is a modern JavaScript feature.
```javascript
const add = (a, b) => a + b;
console.log(add(5, 3)); // 8
```
--------------------------------
### Data Fetching with HttpClient in TypeScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Shows how to fetch data using Angular's HttpClient module in TypeScript. This is a common pattern for interacting with RESTful APIs. The code demonstrates making a GET request and returning an Observable.
```typescript
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ApiService {
private apiUrl = '/api/items';
constructor(private http: HttpClient) {}
getItems(): Observable {
return this.http.get(this.apiUrl);
}
}
```
--------------------------------
### Implement basic authentication with JWT in Node.js
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
This snippet demonstrates how to implement a basic JSON Web Token (JWT) authentication strategy in a Node.js environment. It covers token generation, verification, and middleware setup for protecting routes. Dependencies include 'jsonwebtoken' and 'express'.
```javascript
const jwt = require('jsonwebtoken');
const express = require('express');
const app = express();
const secretKey = 'yourSecretKey'; // Replace with a strong, secret key
// Middleware to verify JWT
function authenticateToken(req, res, next) {
const authHeader = req.headers['authorization'];
const token = authHeader && authHeader.split(' ')[1];
if (token == null) return res.sendStatus(401);
jwt.verify(token, secretKey, (err, user) => {
if (err) return res.sendStatus(403);
req.user = user;
next();
});
}
// Example route for generating a token (e.g., after login)
app.post('/login', (req, res) => {
const username = req.body.username;
const user = { name: username }; // User payload
const accessToken = jwt.sign(user, secretKey, { expiresIn: '1h' });
res.json({ accessToken: accessToken });
});
// Example protected route
app.get('/protected', authenticateToken, (req, res) => {
res.json({ message: 'This is a protected route', user: req.user });
});
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
```
--------------------------------
### Configure DevUI styles in angular.json
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Add the DevUI stylesheet reference to the styles array in angular.json configuration file to apply DevUI design system styling globally to the application.
```json
{
"styles": [
"...",
"node_modules/ng-devui/devui.min.css"
]
}
```
--------------------------------
### Angular Component: Basic Structure
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
A standard Angular component structure, demonstrating the basic decorators and class definition. This is a fundamental building block for any Angular application.
```typescript
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.css']
})
export class ExampleComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
```
--------------------------------
### Angular Template Syntax: Event Binding
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Shows how to bind to DOM events in Angular templates using parentheses `()`. This allows components to respond to user interactions like clicks or input changes. The example binds a click event to a component method.
```html
```
--------------------------------
### API Request Implementation
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
This code snippet shows how to make an API request, likely using the `HttpClient` module in Angular. It demonstrates fetching data from a remote server and handling the response.
```typescript
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class ApiService {
private apiUrl = 'https://api.example.com/data';
constructor(private http: HttpClient) { }
getUsers(): Observable {
return this.http.get(this.apiUrl);
}
}
```
--------------------------------
### C# Basic Console Output
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Demonstrates how to write output to the console in C#. The `Console.WriteLine()` method is used for displaying text and variable values during program execution.
```csharp
using System;
public class HelloWorld
{
public static void Main(string[] args)
{
Console.WriteLine("Hello from C#!");
}
}
```
--------------------------------
### Data Table Rendering (Angular)
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Illustrates how to display data in a table format using DevUI's data table component. This includes binding data to the table and configuring columns.
```html
```
```typescript
import { Component } from '@angular/core';
@Component({
selector: 'app-data-table',
templateUrl: './data-table.component.html'
})
export class DataTableComponent {
data = [{ id: 1, name: 'Item 1' }, { id: 2, name: 'Item 2' }];
columns = [{ field: 'id', header: 'ID' }, { field: 'name', header: 'Name' }];
}
```
--------------------------------
### Fetch Data using Angular HttpClient
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Shows how to use Angular's `HttpClient` module to make HTTP requests, specifically a GET request to fetch data from a given URL. This is a standard practice for interacting with backend APIs in Angular applications. It requires the `HttpClientModule` to be imported.
```typescript
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({ ... })
export class DataDisplayComponent implements OnInit {
data: any;
constructor(private http: HttpClient) {}
ngOnInit() {
this.http.get('/api/items').subscribe(response => {
this.data = response;
});
}
}
```
--------------------------------
### Basic HTML Structure for an Angular Component
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
The corresponding HTML template for an Angular component, showing how data binding and event handling might be implemented. This is typically used with an Angular component.
```html
{{ pageTitle | capitalize }}
{{ pageDescription }}
{{ item.name }}
```
--------------------------------
### Complete Download Configuration Example
Source: https://github.com/devcloudfe/ng-devui/blob/master/devui/common/doc/api-en.md
Comprehensive example combining all download options including headers, progress tracking, credentials, error handling, and success callbacks for a production-ready file download implementation.
```TypeScript
// Complete download configuration
const completeDownloadConfig = {
// Request configuration
header: {
'X-lang': 'en',
'Authorization': 'Bearer token'
},
enctype: 'application/x-www-form-urlencoded',
// Response handling
responseOption: 'json',
filename: 'document.pdf',
downloadWithoutDispositionHeader: false,
// Credentials and progress
withCredentials: true,
reportProgress: true,
// Callbacks
onSuccess: (res: HttpResponse) => {
const blob = new Blob([res.body], { type: 'application/pdf' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = res.headers.get('filename') || 'download.pdf';
link.click();
window.URL.revokeObjectURL(url);
},
onError: (res: any) => {
console.error('Download error:', res);
alert('Download failed: ' + (res.message || 'Unknown error'));
}
};
```
--------------------------------
### Configure a Route in Angular
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Demonstrates how to define a route configuration in an Angular application. This snippet is crucial for setting up navigation between different views or components. It maps a URL path to a specific component.
```typescript
import { Routes } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
export const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'about', component: AboutComponent }
];
```
--------------------------------
### Dynamic Component Loading
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
This code illustrates the dynamic loading of Angular components at runtime. This pattern is often used for creating flexible UIs, such as modal dialogs or dynamically generated forms.
```typescript
import { ComponentFactoryResolver, ViewContainerRef, Injector, ComponentRef, OnInit, OnDestroy, ViewChild, Component } from '@angular/core';
@Component({
selector: 'app-dynamic-host',
template: ''
})
export class DynamicHostComponent implements OnInit, OnDestroy {
@ViewChild('dynamicContent', { read: ViewContainerRef }) vcr!: ViewContainerRef;
componentRef!: ComponentRef;
constructor(private componentFactoryResolver: ComponentFactoryResolver, private injector: Injector) {}
ngOnInit() {
const factory = this.componentFactoryResolver.resolveComponentFactory(SomeDynamicComponent);
this.componentRef = this.vcr.createComponent(factory, 0, this.injector);
// You can interact with the created component instance here
}
ngOnDestroy() {
if (this.componentRef) {
this.componentRef.destroy();
}
}
}
// Assume SomeDynamicComponent is defined elsewhere
@Component({ template: '
I am dynamic!
' })
class SomeDynamicComponent {}
```
--------------------------------
### Use UserGuide as a Service (TypeScript)
Source: https://github.com/devcloudfe/ng-devui/blob/master/devui/user-guide/doc/api-en.md
Illustrates how to use the UserGuideService for more programmatic control. This involves injecting the service and calling its methods like `setSteps` and `start`.
```typescript
import { UserGuideService } from 'ng-devui/user-guide';
constructor(private userGuideService: UserGuideService) { }
ngOnInit() {
this.userGuideService.setSteps(this.steps);
}
startTutorial(index: number) {
this.userGuideService.start(index);
}
```
--------------------------------
### Create Angular Project
Source: https://github.com/devcloudfe/ng-devui/blob/master/README.md
Command to generate a new Angular project using the Angular CLI. This is the initial step before installing DevUI.
```bash
ng new New-Project
```
--------------------------------
### IStep Interface Definition
Source: https://github.com/devcloudfe/ng-devui/blob/master/devui/user-guide/doc/api-en.md
Defines the structure for a single set of guided tutorials, including properties for title, description, step details, and configuration options for appearance and behavior.
```typescript
export interface IStep {
title: string; // Title of this set of guidelines
desc?: string; // Description of this set of guidelines
showDots?: boolean; // Whether to show step points
maxContentWidth?: number; // Maximum width of the content area
defaultStart?: boolean; // Whether to start this tutorial automatically after the page finishes loading
isCover?: boolean; // Whether there is a mask layer
extraConfig?: IUserGuideExtraConfig; // Guide Panel Configuration Items
onExit?: Function; // Callback function on exit
detail: Array; // Specific steps in this set of guidelines
}
```
--------------------------------
### Basic HTML Structure
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
A minimal HTML5 document structure. This serves as a foundational template for any web page, including the ``, ``, ``, and `` tags. It's language-agnostic but fundamental to web development.
```html
Document
Hello, World!
```
--------------------------------
### Use UserGuide as a Component
Source: https://github.com/devcloudfe/ng-devui/blob/master/devui/user-guide/doc/api-en.md
Shows how to integrate the UserGuide component directly into your HTML templates. It requires binding an array of steps to the `steps` input property.
```html
```
--------------------------------
### Handling User Input and Display
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-cn.md
This snippet demonstrates how to handle user input and display it. It includes examples of input fields and how to render the entered text. Dependencies include basic HTML and JavaScript.
```html
```
--------------------------------
### Import DevUI modules in Angular AppModule
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Configure the root AppModule to import BrowserModule, BrowserAnimationsModule (required for DevUI animations), and DevUIModule. This enables all DevUI components for use throughout the application.
```typescript
import { BrowserModule } from '@angular/platform-browser';
// Some DevUI components depend on the Angular animation, and the animations module needs to be introduced.
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { DevUIModule } from 'ng-devui';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
DevUIModule
],
bootstrap: [ AppComponent ]
})
export class AppModule {}
```
--------------------------------
### HTML List (Unordered)
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Illustrates an unordered HTML list (`
`). Unordered lists are used to display items in a bulleted format. Each list item is defined using the `
` tag.
```html
Item 1
Item 2
Item 3
```
--------------------------------
### Basic HTML Structure
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Provides a minimal HTML document structure. This serves as the foundation for web pages, including the ``, ``, ``, and `` tags. It's essential for any web development context.
```html
Document
```
--------------------------------
### downloadFile Usage Example - TypeScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/devui/common/doc/api-en.md
Demonstrates practical usage of the downloadFile method with various options. Shows examples for POST requests with parameters, custom encoding types, and error handling callbacks.
```typescript
// Basic GET request
downloadFile('/api/files/report.pdf');
// POST request with parameters
downloadFile('/api/files/download', {
method: 'POST',
params: {
fileId: '12345',
format: 'pdf'
},
enctype: 'application/x-www-form-urlencoded'
});
// With custom iframe name and error handling
downloadFile('/api/export/data', {
method: 'post',
params: { exportType: 'csv' },
iframename: 'customDownloadFrame'
}, (response) => {
console.error('Download failed:', response);
});
```
--------------------------------
### Basic Java Structure (KKK) - Continued
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-cn.md
This snippet continues the repetitive Java code structure, following the pattern '//U+/qKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD//V+/qKKKACiiigAooooAKKKKACiiigAooooAKKKKACkyfSg+1Rr39c85oAeTilzTG3Y4x704eooAXNGaMUYoAM0ZoxRigAzRmjFGKADNGaMUYoAM0ZoxRigAzRmjFGKADNGaMUYoAM0ZoxRigAzRmjFGKAEz6c0ZNHbNJ0oAdnFBOKjPBGfwpx3dsZxxQA4GjNMXd/F174p+KAFzRSYpaACmkkDgU6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NH/QxSf9+ov/AImj/hpb40f9DFJ/36i/8AiaAPhKivtH/4aW+NH/QxSf9+ov/AImj/hpb40f9DFJ/36i/8AiaAPhKivtH/4aW+NH/QxSf9+ov/AImj/hpb40f9DFJ/36i/8AiaAPhKivtH/4aW+NH/QxSf9+ov/AImj/hpb40f9DFJ/36i/8AiaAPhKivtH/4aW+NH/QxSf9+ov/AImj/hpb40f9DFJ/36i/8AiaAPhKivtH/4aW+NH/QxSf9+ov/AImj/hpb40f9DFJ/36i/8AiaAPhKivtH/4aW+NH/QxSf9+ov/AImj/hpb40f9DFJ/36i/8AiaAPhKivtH/4aW+NH/QxSf9+ov/AImj/hpb40f9DFJ/36i/8AiaAPhKivtH/4aW+NH/QxSf9+ov/AImj/hpb40f9DFJ/36i/8AiaAPhKivtH/4aW+NH/QxSf9+ov/AImj/hpb40f9DFJ/36i/8AiaAPhKivtH/4aW+NH/QxSf9+ov/AImj/hpb40f9DFJ/36i/8AiaAPhKivtH/4aW+NH/QxSf9+ov/AImj/hpb40f9DFJ/36i
--------------------------------
### Basic HTML Structure for a Web Page
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
A fundamental HTML structure for a basic web page. It includes the DOCTYPE declaration, html tag with language attribute, head section for metadata and title, and a body section for content. This serves as a template for new web pages.
```html
Document
```
--------------------------------
### Import UserGuide Module
Source: https://github.com/devcloudfe/ng-devui/blob/master/devui/user-guide/doc/api-en.md
Demonstrates how to import the UserGuideModule into your Angular module to enable its functionality. This is a prerequisite for using the UserGuide component or service.
```typescript
import { UserGuideModule } from 'ng-devui/user-guide';
```
--------------------------------
### IUserGuideExtraConfig Interface Definition
Source: https://github.com/devcloudfe/ng-devui/blob/master/devui/user-guide/doc/api-en.md
Defines optional configurations for customizing the appearance of the UserGuide panel, such as background color, button types, and text colors.
```typescript
export interface IUserGuideExtraConfig {
panelBackground?: string; // Guide Panel Background Color
nextButtonType?: string; // Next button type
infoColor?: string; // Content Color
operationColor?: string; // Operation color
dotColor?: string; // Navigation Point Color
}
```
--------------------------------
### Asynchronous Operation Example in TypeScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Demonstrates an asynchronous operation using async/await syntax in TypeScript. This snippet likely handles fetching data or performing a long-running task without blocking the main thread. It utilizes Promises for managing asynchronous results.
```typescript
async function example() {
try {
const result = await someAsyncOperation();
console.log(result);
} catch (error) {
console.error(error);
}
}
```
--------------------------------
### Basic DevUI Card Component Structure in HTML
Source: https://github.com/devcloudfe/ng-devui/blob/master/devui/card/doc/api-en.md
This example demonstrates the fundamental HTML structure for implementing a DevUI card component. It includes slots for header, content, and actions, along with specific sub-components like `d-card-title` and `d-card-content`.
```html
```
--------------------------------
### Creating a Custom Pipe in TypeScript (Angular)
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
Illustrates how to create a custom pipe in Angular using TypeScript. Pipes are used to transform data in templates. This example shows a simple pipe that might format dates or currency. It requires the `Pipe` decorator and `PipeTransform` interface.
```typescript
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'myCustomPipe' })
export class MyCustomPipe implements PipeTransform {
transform(value: string, args?: any): string {
// Transformation logic here
return value.toUpperCase();
}
}
```
--------------------------------
### User Registration API
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-cn.md
Allows new users to register an account by providing their credentials.
```APIDOC
## POST /api/users/register
### Description
Registers a new user with the provided details.
### Method
POST
### Endpoint
/api/users/register
### Parameters
#### Request Body
- **username** (string) - Required - The desired username for the new account.
- **email** (string) - Required - The user's email address.
- **password** (string) - Required - The user's chosen password.
### Request Example
```json
{
"username": "john_doe",
"email": "john.doe@example.com",
"password": "securepassword123"
}
```
### Response
#### Success Response (201)
- **message** (string) - Indicates successful registration.
- **userId** (string) - The unique identifier for the newly created user.
#### Response Example
```json
{
"message": "User registered successfully.",
"userId": "user12345"
}
```
#### Error Response (400)
- **error** (string) - Describes the reason for the registration failure (e.g., "Username already exists.").
```
--------------------------------
### Get String Length in JavaScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
This JavaScript function returns the length of a given string. It uses the .length property of the string object.
```javascript
function a(r: string) {
return r.length;
}
```
--------------------------------
### Check if String Starts With Substring in JavaScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
This JavaScript function checks if a string begins with a specified substring. It uses the String.prototype.startsWith() method, which is case-sensitive.
```javascript
function a(r: string, e: string) {
return r.startsWith(e);
}
```
--------------------------------
### Get Current Timestamp in JavaScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
This JavaScript snippet returns the current timestamp in milliseconds since the Unix epoch. It uses the Date.now() method.
```javascript
function a() {
return Date.now();
}
```
--------------------------------
### Define IStepElement Interface for Guide Steps (TypeScript)
Source: https://github.com/devcloudfe/ng-devui/blob/master/devui/user-guide/doc/api-en.md
The IStepElement interface defines the structure for individual steps in a user guide. It includes properties for associating elements, setting titles and content, defining positioning and interaction types, and handling callbacks. This interface is crucial for implementing interactive tutorials.
```typescript
export interface IStepElement {
element?: object; // Element associated with the guide step, which can be a class name or ID name.
title: string; // Title of the guide step.
content?: string | TemplateRef; // Description of the guide step, which can be character strings, HTML or TemplateRef.
position?: PositionType; // Position of the pop-up window. If this parameter is not transferred, a proper position is automatically selected.
type: 'normal' | 'interactable'; // Guidance Mode Type
// The default value is normal, indicating the general guidance mode. If the value of element is not undifined, locate the element and highlight the current step. The page and element cannot be clicked. If the value of element is undifined, no specific element is located, and the general information is displayed in the guide window. Other areas of the page cannot be clicked.
// The second mode is interactive. The blue box and breathing action are used to highlight step elements. Users can click elements for dynamic interaction. The eventType parameter must be used together with the eventType parameter. Currently, three types of interaction events are provided: click event, input event, and exit event.
// The third is the'tip' prompt box mode, which is suitable for some step-by-step instructions that highlight the user.
eventType?: 'clickable' | 'inputable' | 'exit'; // Interactive Event Types
// Clickable is a clickable event. After a user clicks an element, the user clicks an additional operation and proceeds to the next step. It is usually used to open a pop-up window or drop-down menu after the user clicks the element.
// "inputable" is an inputable event. The user can click the auxiliary area of the guide window to automatically enter the event. The user can automatically enter the event or enter the information in the input box to complete the interaction and display the Next button.
// 'exit' is an exit event that automatically closes the tutorial at the last step of the tutorial and prompts the user to complete the tutorial.
highlightOffset?: Array;
//Offset of the highlighted region. The format is [up, right, bottom, left]. The unit is px.
inputData?: string; //Allows you to enter the content automatically entered by the event. This parameter is mandatory when eventType is set to inputable.
waitingTime?: number; //Event Waiting Time
beforeChange?: Function | Promise | Observable; // User callback function before the start of each step. If no return value is returned or the return value is true, go to the next step.
showPrevButton?: boolean; // Whether to display the previous button
}
```
--------------------------------
### Get Current Date in 'MM/DD/YYYY' Format in JavaScript
Source: https://github.com/devcloudfe/ng-devui/blob/master/src/app/component/getStarted-en.md
This JavaScript snippet gets the current date and formats it into a 'MM/DD/YYYY' string. It creates a new Date object and then formats it using the logic from the 'Format Date to MM/DD/YYYY' function.
```javascript
function a() {
const r = new Date();
const e = (r.getMonth() + 1).toString().padStart(2, '0');
const t = r.getDate().toString().padStart(2, '0');
const n = r.getFullYear();
return `${e}/${t}/${n}`;
}
```
--------------------------------
### HTML Examples for DevUI Layout Directives
Source: https://github.com/devcloudfe/ng-devui/blob/master/devui/layout/doc/api-en.md
Provides various HTML examples showcasing the usage of d-row, d-col, dFlex, dSpace, dGutter, dClass, and dStyle directives for creating grid and flexbox layouts.
```html