angular


*ngIf condition is not fired/doesn't update template in ngOnChanges


I have a child a component that does not fire the condition for *ngIf
child component:
export class child {
#Input() user;
#Input() list;
listLength: number;
showBtn: boolean = false;
constructor(){}
ngOnChanges(changes: SimpleChanges){
this.userId = this.user.id;
this.userList = this.list;
this.listLength = this.userList.length; // this updates everytime when changes happen on another component thats pushed from this component.
if (this.listLength > 3){ // this doesn't fire until I refresh the page
this.showBtn = true;
}
You probably also get an error output in the browsers console.
Invoke change detection explicitly if you update the model in ngOnChanges()
constructor(private cdRef:ChangeDetectorRef){}
ngOnChanges(changes: SimpleChanges){
this.userId = this.user.id;
this.userList = this.list;
this.listLength = this.userList.length; // this updates everytime when changes happen on another component thats pushed from this component.
if (this.listLength > 3){ // this doesn't fire until I refresh the page
this.showBtn = true;
}
this.cdRef.detectChanges();
}
}

Related Links

How do I create an autocomplete in angular-material2?
PouchDb is not working electron and angular4
Angular 2 auth seems not to work, although I receive a success message
Getting/creating ViewContainerRef without ViewChild query
After using “ionic run android” to deploy the app to phone, still exists the cross-domain?
Chat App not proper work in angularfire2
onClick function in Chart.js passing the selected object, Typescript
You may need an appropriate loader to handle this file type. Typescript
when i run npm i got this error. how to fix this?
Angular2 add nativeElement to component's prototype
Property 'value' does not exist on type 'ElementRef'
Getting all routes from current module - Angular 2
Ionic 2 Cache issue with tabs application
Set selected option by default on angular template
Downloading Redux State into an Angular 2 component and then iterating over its result
How to push on FormArray without FormBuilder on Angular 2

Categories

HOME
node.js
hyper-v
rstudio
google-analytics
momentjs
openerp
ruby-on-rails-4
multidimensional-array
alexa
payment
ignite
luigi
scenekit
zurb-foundation
uwp-xaml
timezone
android-gradle
formula
google-cardboard
datepicker
sourceforge
log4net
ascii
jlabel
pixel
twitter-typeahead
sdl
google-app-invites
azure-storage-blobs
react-apollo
cookie-session
phylogeny
floyd-warshall
ebcdic
biblatex
chinese-locale
bing-api
android-logcat
pgadmin
protobuf-c
inorder
nexmo
layer
gsutil
userfrosting
nsubstitute
meta-tags
smartassembly
spring-cloud-sleuth
automated-deployment
configuration-files
media-type
gold-parser
winlims
audiounit
react-d3
run-configuration
matlab-uitable
proof-of-correctness
c++1z
smartmeter
unicode-string
sceditor
satellite
nsoutlineview
google-chartwrapper
rpath
raptor
flowgear
agile-project-management
antivirus-integration
lunrjs
simplify
firefox-addon-bootstrap
into-outfile
rgraph
octopress
8085
meter
vin
networkcredentials
ilias
knockout-mapping-plugin
impactjs
linq-to-lucene
factoring
pivotitem
server-side-scripting
cgimagesource
iwebkit
nservicebus3
ejbql
enctype
custom-view
scopes
sqa
codeigniter-datamapper
silverlight-embedded
xmlnodelist
rakefile
application-design
orbited
vmwaretasks

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile