builder icon indicating copy to clipboard operation
builder copied to clipboard

@builder.io/angular Data passing and custom actions not persist in builder.io state

Open lyczos opened this issue 5 years ago • 12 comments

Hello, I trying to pass data to builder component like this

<builder-component *ngIf="visible"
                     [data]="data"
                     [model]="computedModel$ | async"
                     [options]="optionsCombined"
                     [reloadOnRoute]="false"
                     [handleRouting]="true"
                     [prerender]="false"
                     [navigationTimeout]="false"
                     (load)="load($event)"
                     (route)="routeChanged($event)"
                     (error)="error($event)">
 </builder-component>

The data includes some properties: data = { myFunc: () => alert('wooow!'), b: 'c'};

But when I tried to read it from the state in builder.io I am getting an error:

Builder custom code error: state.myFunc is not a function in console.log(state.myFunc()) 

image

I am 100% it was working fine a few months back.

Note: I am using prerender=flase Note 2: Not working with "@builder.io/angular": "1.1.10" and "@builder.io/angular": "1.1.11-alpha.2"

lyczos avatar Jun 26 '20 09:06 lyczos

We may have a fix for this, going to test it out locally now. I'll update this issue when I have more information.

ca136 avatar Jun 26 '20 14:06 ca136

Thanks @ca136 , waiting for feedback :)

lyczos avatar Jun 29 '20 06:06 lyczos

https://github.com/BuilderIO/builder/pull/192 for reference. due to Angular issues it's hard to test with npm linking so still want to make sure it doesn't break anything. Will have a pre-release candidate for you to test hopefully today.

ca136 avatar Jun 29 '20 16:06 ca136

@lyczos can you give this version a try locally or on your dev site and let me know if the function binding and all of your other content rendering works: @builder.io/angular: "1.1.11-alpha.3"

ca136 avatar Jun 29 '20 16:06 ca136

@ca136 After version update inside builder.io editor: image

The page is not rendering at all ;(

lyczos avatar Jun 30 '20 08:06 lyczos

Got it thanks for testing, do you mind sharing your <builder-component> snippet?

ca136 avatar Jun 30 '20 13:06 ca136

Got it thanks for testing, do you mind sharing your <builder-component> snippet?

Sure @ca136 , it is already in issue report :)

<builder-component *ngIf="visible" <-- true after route change
                     [data]="data" <--  { myFunc: () => alert('wooow!'), b: 'c'}
                     [model]="computedModel$ | async" <-- "page"
                     [options]="optionsCombined"  <-- {cacheSeconds: 1000}
                     [reloadOnRoute]="false"
                     [handleRouting]="true"
                     [prerender]="false"
                     [navigationTimeout]="false"
                     (load)="load($event)"
                     (route)="routeChanged($event)"
                     (error)="error($event)">
 </builder-component>

lyczos avatar Jun 30 '20 14:06 lyczos

Ok thanks :D can you give this a shot: @builder.io/angular: 1.1.12-1

ca136 avatar Jul 06 '20 22:07 ca136

@ca136 @builder.io/angular: 1.1.12-1

data = {
    please: () => alert('I have a hope it will work!'),
    noWay: 'a'
  };

In builder: image

Output after click event: image

I've checked also old versions and it seems to not work too "@builder.io/angular": "1.0.83", so maybe the issue is with some scripts from yours builder.io /dist

lyczos avatar Jul 07 '20 12:07 lyczos

@lyczos I took a deeper look at this and the fix looks more complicated than we originally envisioned. We plan on re-writing our Angular SDK in the next couple of weeks, and we can make sure support for this gets into that project. The new version should be a lot simpler, lighter weight and easier to contribute to. Please let us know if you have any questions in the meantime.

ca136 avatar Jul 30 '20 15:07 ca136

@ca136 is this issue resolved?

vishalvora avatar Oct 11 '21 17:10 vishalvora

@ca136, any progress with this issue?

tomekknowde avatar May 18 '22 04:05 tomekknowde