Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

angular classic component

Hi,

Can I customize the classic component in way that works differently for different pages, it seems it is common for all the pages for the demo, whether it is Dashboard, Layout builder or any.

  1. Say for example for Page 1 I have some set of filters and for Page 2 they are different
  2. also for some of the pages I dont want those buttons visible at all or different buttons according to the requirement
  3. for different pages I want Create to be redirected to the respective add pages

click here for image

Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)

Hi Rohan,

We don't have a specific guide tailored to your exact scenario, but I can provide you with a general idea of how you can achieve the functionality you're looking for in Angular. Please note that the following code examples are simplified and you may need to adapt them to your specific implementation:

  1. Custom Filters: To have different sets of filters for different pages, you can create a component property to hold the filters and pass them from the parent component. For example:
    // Inside the component class
    @Input() filters: any[] = [];
    
    
  1. Conditional Visibility: To show/hide buttons based on specific requirements or for certain pages, you can use Angular's structural directives like ngIf. Here's an example:
    
    

Make sure to define the boolean properties showButton1 and showButton2 in your component and set their values based on the desired conditions.

  1. Dynamic Redirection: To redirect the "Create" button to different add pages based on the current page, you can utilize Angular's Router module. Here's a simplified example:
    import { Router } from '@angular/router';

    constructor(private router: Router) {}

    redirectToAddPage() {
    // Determine the appropriate add page URL based on the current page
    let addPageUrl: string;

    // Logic to set the addPageUrl based on the current page

    // Redirect to the add page
    this.router.navigate([addPageUrl]);
    }

In this example, you'll need to define the logic to determine the appropriate addPageUrl based on the current page. Make sure to import the Router module and inject it into your component's constructor.

These code examples provide a starting point for achieving the functionality you described. You'll need to adapt them to fit your specific requirements and integrate them into your Angular project accordingly.

Thanks


Hi Rohan,

Yes, you can customize the Angular classic component to work differently for different pages. Here are some approaches you can take to achieve the desired customization:

Custom Filters: To have different sets of filters for different pages, you can make the filters configurable by using input properties. For example, you can create an input property called filters and pass different filter configurations to the component based on the page. Inside the component, you can then use these filter configurations to display the appropriate filters.

Conditional Visibility: If you want to show/hide buttons based on specific requirements or for certain pages, you can use conditional rendering techniques. You can add boolean input properties to control the visibility of buttons and set their values based on the requirements or page context. Inside the component's template, you can use Angular's structural directives like ngIf to conditionally render or hide buttons based on these input properties.

Dynamic Redirection: If you want the "Create" button to redirect to different add pages based on the current page, you can again use input properties to pass the respective page URLs to the component. Inside the component's logic, you can handle the button click event and programmatically navigate to the appropriate add page using Angular's Router module.

You can customize the component to adapt to different pages with varying filters, button visibility, and redirection behaviors. Leverage Angular's component-based architecture and features like input properties, conditional rendering, and routing to achieve the desired customization.

If you need further assistance or have specific questions regarding implementation details, feel free to ask.


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(