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

Access process.env in environment.ts file created from the angular-cli
Cannot read property 'channels' of undefined youtube api
How to set the public path on angular 4
Using local Bootstrap3 with angular 2
Firebase: update database when no write operation happens in 5 minutes interval
Build single directive to perform both Structural & Attribute behaviour?
Angular 2 Sending data to child
AOT - Function calls are not supported Module.forRoot
subscribe to ionic page change event
Dynamic number of Promise in Angularfire2
Drag and drop doesn't call change event in ie/edge angular2
Angular2 routing issue and ngOnInit called twice
angular 2.4.1 on IE10- dont work 4 me
Angular 2 MVW - MVC, MVA, MVP, MVVM?
Confirm dialog inject it or hide it (performance)
Angular 2 - load component from its own file, instead of on the module file

Categories

HOME
videochat
google-analytics
firebase-authentication
text
g2o
keen-io
animate.css
speech-recognition
mutex
asp.net-web-api2
chat
bluetooth-lowenergy
crc
netfilter
pivot-table
crystal-reports-xi
playframework-2.5
bigdata
shoutem
angularjs-ng-transclude
ninja
pthreads
row-number
redactor
miktex
jqxwidgets
navigation-drawer
pgadmin
mahapps.metro
reactive-streams
tornado-motor
angular-daterangepicker
lektor
basic4android
angularjs-ng-model
nn
war
gooddata
meta-tags
moa
digestive-functors
model-driven
jes
cakephp-2.x
exceljs
friend-function
run-configuration
django-compressor
jedi-vim
monocle-scala
simplehttpserver
rpy2
outlook-2016
archiving
arithmetic-expressions
grid-layout
nscoding
sos
ibm-jazz
cosmos
fileapi
wave
date-arithmetic
enplug-sdk
centura
jquery-dynatree
class-relationship
sqloledb
stacked-area-chart
editplus
resharper-plugins
deface
angularjs-ng-show
openacs
apache-commons-exec
galera
maptiler
where-in
amber-smalltalk
jsonexception
opengl-es-1.1
ipad-2
sequence-alignment
system-design
abpeoplepickerview
flotr
continuations
validationsummary
trx
widechar
microsoft.build

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App