Knobs with angular component not updating
See original GitHub issueDescribe the bug When using props on a component, the values of the knobs are not available in the component.
To Reproduce See code snippet
Expected behavior
I expect the value within the component to be updated when I type in the text
knob
Screenshots If applicable, add screenshots to help explain your problem.
Code snippets
import {storiesOf, moduleMetadata} from '@storybook/angular';
import {Component, Input} from '@angular/core';
import {withKnobs, text} from '@storybook/addon-knobs';
import {FormsModule} from '@angular/forms';
@Component({
selector: 'simple-component',
template: `
{{ name || 'default' }}
<input type="text" [(ngModel)]="name" />
`,
})
export class SimpleComponent {
@Input() name: string;
}
storiesOf('component', module)
.addDecorator(withKnobs)
.addDecorator(
moduleMetadata({
imports: [FormsModule],
declarations: [SimpleComponent],
}),
)
.add('notWorking', () => ({
component: SimpleComponent,
props: {
name: text('Name', 'outer name'),
},
}));
System:
- OS: [MacOS]
- Browser: [chrome]
- Framework: [angular]
- Addons: @storybook/addon-knobs @storybook/addon-notes @storybook/addon-viewport @storybook/addon-storysource storybook-addon-designs
- Version: “@storybook/addon-actions”: “^5.0.11”, “@storybook/addon-centered”: “^5.0.11”, “@storybook/addon-knobs”: “^5.0.11”, “@storybook/addon-notes”: “^5.0.11”, “@storybook/addon-storysource”: “^5.0.11”, “@storybook/addon-viewport”: “^5.0.11”, “@storybook/angular”: “^5.0.11”, storybook-addon-designs: 5.0.0
Below I expected to see ‘Updated’ (which is the value typed in the knob)next to the input but it still shows the default value
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:9
Top Results From Across the Web
Angular 5 Component Not Updating When Observable Returns
I decided to attempted to run ChangeDetectorRef.detectChanges(); after I update the property of the component. Doing this actually fixed my ...
Read more >Angular Semi Knob not working - Forums - jQWidgets
Hello iwagner, The issue seems to come from the setup of the Angular Application, rather than the Knob element. projects. $projectName.
Read more >Observables compared to other techniques - Angular
Observables are declarative; computation does not start until subscription. Promises execute immediately on creation. · Observables provide many values.
Read more >Security - Angular
This topic describes Angular's built-in protections against common web-application vulnerabilities and attacks such as cross-site scripting attacks.
Read more >Adding navigation - Angular
View product detailslink. The ProductDetailsComponent handles the display of each product. The Angular Router displays components based on the browser's URL and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi all,
I’ve found a workaround. Use functions!! As you may know, React is all about functions and so are knobs, with this approach, you have instant responsiveness:
Hey, has anybody had a chance to look at this? It’s not blocking as we can wrap the component in a template but it’s extra effort to duplicate the bindings when they’re already there. Thanks a lot