Send the ObservableArray to the Model dialog parameters to display the data from RadListView as [Object Object]

When passing an Observable array to modal dialog params, I encountered an issue where opening the dialog displayed [object Object] when using RadListView. However, everything worked fine with ListView except for RadListView.

HomeComponent.ts:

 public obsArr: ObservableArray<App>;
    ngOnInit(){
        this.obsArr= this.homeService.getMyApps();
      }

       const options = {
            context: this.obsArr,
            fullscreen: true,
            viewContainerRef: this.vcRef
          };
          this.modal.showModal(FirstComponent, options).then((resource) => {
          });

FirstComponent.ts: (Modal dialog)

  public firstAppArr: ObservableArray<App>;

    constructor(private params: ModalDialogParams, private routerExtensions: RouterExtensions) {
    }

    ngOnInit() {

        this.firstAppArr= this.params.context;
    }

first_component.html: (Modal dialog html)

<RadListView [items]="firstAppArr" itemReorder="true">
    <ng-template let-item="item" let-i="index">
        <GridLayout rows="auto" columns="*,*">
            <StackLayout col="0" horizontalAlignment="left" verticalAlignment="center">
                <Label [text]="item.name" textWrap="true"></Label>
            </StackLayout>

            <StackLayout col="1" horizontalAlignment="right" verticalAlignment="center">
                <Label [text]="item.description" textWrap="true"></Label>

            </StackLayout>     
        </GridLayout>
    </ng-template>      
</RadListView>

Answer №1

At this moment, you are assigning firstAppArr to an object containing {"_observers":{}, "_array":[]}, which is not the array you need. My recommendation would be to modify your ngOnInit() like so:

ngOnInit() {
    // if you have both context and array
    this.firstAppArr = this.params.context._array;

    // if you're unsure about context or array presence. this will set it as _array or undefined
    this.firstAppArr = this.params && this.params.context. && this.params.context._array;
}

This adjustment will enable you to access the array part of your object.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can we utilize lodash debounce to debounce a function within the modelChange function?

I need help with utilizing a debounced function within my modelChange function. Whenever the model changes, this function is invoked. Currently, I am attempting to use lodash's debounce feature, but it doesn't seem to be triggering the function. ...

Display Bootstrap Modal Box automatically when Angular 8 App Loads

I am facing an issue with launching a modal dialog on page load in my Angular 8/Visual Studio project. While it works perfectly fine with the click of a button, I am unable to make it load automatically on page load. I have tried using *ngIf but it doesn&a ...

Tips for writing unit tests for clipboard copy functionality in an Angular application

How can we monitor the behavior of the clipboard.copy method? For const clipboard = TestBed.inject(Clipboard); spyOn(clipboard, 'copy').and.returnValue(true); An error warning pops up indicating that Argument of type '"copy"' ...

Processing a list in Angular using Observables

In my Angular12 application, I am fetching data from a Firebase Realtime DB using AngularFire. To streamline my code and ensure consistency, I have implemented a DAO service to preprocess the retrieved data (e.g., converting string dates to Date objects). ...

The styles from bootstrap.css are not displaying in the browser

Currently in the process of setting up my angular 2 project alongside gulp by following this helpful tutorial: I've added bootstrap to the package.json, but unfortunately, it's not reflecting in the browser. I can see it in the node_modules and ...

Having trouble retrieving data from Spotify API within Angular application

Upon attempting to retrieve a json response from the Spotify API, I encountered the following error: XMLHttpRequest cannot load https://api.spotify.com/v1/search?query=eminem&offset=0&limit=20&type=artist&market=US. Request header field Ac ...

Turning Typescript into Javascript - the How-To Guide

Currently following Shopify's Node Api tutorial to implement a Redis store in my project. The tutorial provides code in typescript, but my entire project is in javascript (React/nextjs). I've been struggling to convert the code to javascript for ...

Identify all the CHECKBOX elements that are visible and not concealed

On my page, I have various checkboxes - some with hidden=true and others with hidden=false attributes. Despite trying to use a selector or jQuery to locate checkboxes with the hidden property, I am still facing some challenges. My goal is to differentiate ...

What is the best way to instruct TypeScript to utilize a globally installed NPM @types package?

After running npm install @types/node, the TypeScript compiler worked perfectly with tsc -p tsconfig.json. However, when I attempted to install the package globally with npm install -g @types/node and deleted the local folder, I encountered the following ...

Creating a tailored regular expression for validating email addresses

Up to this point, I have crafted a regex pattern as Pattern="^(?=.*[a-zA-Z].*)([a-zA-Z0-9._%+-]+@([a-zA-Z0-9-]+[a-zA-Z0-9-]+(\.([a-zA-Z0-9-]+[a-zA-Z0-9-])+)?){1,4})$" that meets the following criteria: Not all characters should be numbers, ...

Is it possible to convert any object field that holds an empty string to null without having to iterate through

We have an object with values assigned but some of them are empty. Here is the object: { value1: 'bacon', value2: '', value3: 'lard', value4: '', value5: 'cheese', }; Can we transform ...

Developing advanced generic functions in Typescript

I am currently working on a Hash Table implementation in Typescript with two separate functions, one to retrieve all keys and another to retrieve all values. Here is the code snippet I have so far: public values() { let values = new Array<T>() ...

The dropdown menus in Bootstrap are expanding outside the screen when opened

When I click on the dropdown in the Navbar on the right side, the menus open up far to the right and are not visible until I scroll horizontally. Here is the code snippet: <nav class="navbar navbar-expand-lg navbar-light bg-light"> < ...

Tips for resolving the issue when Chrome is able to load the page but Postman cannot find it

I'm encountering a perplexing situation that is entirely new to me and difficult to comprehend. I find myself unable to decipher what exactly I am witnessing, leading to uncertainty about why it is occurring, not to mention the challenge of determinin ...

Angular 5 error handler does not support service calls

My HTTP calls are placed inside a service, as they should be. Within that service, I inject another service for handling error notifications. In an interesting turn of events, I noticed that when I place the notification call inside the catchError pipe, e ...

Need assistance with the Angular polyfill.ts file? Wondering where to place the polyfill code and how to manage it effectively?

Currently encountering an error in my Angular project that requires some 'polyfilling'. Due to the restriction on editing webpack.config.js directly, it seems necessary to work with the polyfill.ts file instead. The issue lies in the fact that An ...

Automatically assign the "Restricted" cursor to disabled fields within a dynamic form

Is there a method in Angular 6/7 that allows the cursor to change to "Not Allowed" when hovering over a disabled field in a reactive form? I prefer not to use CSS for this cursor change. Is there a way to achieve this through Angular alone? Currently, th ...

Utilizing React Typescript to dynamically render a duo of components

On a single page, I want to display two components simultaneously. There is a bottom navbar that, when clicked on, for example the profile icon, should render the profile page. However, I would like to change the color of the icon based on which component ...

How to replace/redirect the import statement in TypeScript from { X } to 'Y'

My situation involves an external library known as Y, which was installed using npm and loaded from the node_modules directory. This library is hosted on GitHub and currently being utilized in my project in the following manner: import { X } from 'Y& ...

Finding parameters in Angular 4

I am working on implementing a multilanguage feature in an Angular app and I need to establish the default language when the site loads. The two languages supported are Spanish and English, with Spanish being the default language. In order to achieve this, ...