Posts

Showing posts with the label angularjs-directive

ngModel displays identical values for different fields

ngModel displays identical values for different fields This is an Angular 5 and Firestore project. I am using a form with [(ngModel)] to update a document in the database. The update is successful. But the way [(ngModel)] displays document field values in the input boxes themselves is incorrect, e.g. the placeholders are wrong. Each input box is displaying the same field value, when they should be different. For example [(ngModel)] [(ngModel)] In the db, my doc looks like this document field1: document title field2: google field3: https://www.google.com But my input boxes show this input box 1 displays https://www.google.com input box 1 https://www.google.com input box 2 displays https://www.google.com input box 2 https://www.google.com input box 3 displays https://www.google.com input box 3 https://www.google.com Here is the HTML <ng-container *ngFor="let x of xyz | async"> update {{x.field1}} #...

Go to top page button after scrolling down

Go to top page button after scrolling down I created a method that go to the top of the page every time I click on it. The problem is, I want this button to be shown only if you already scrolled down and not just as default. How can I define it? Here is my code: show/hide the button - doesn't work: scrollFunction() { if (document.body.scrollTop > 5 || document.documentElement.scrollTop >5) { document.getElementById("myBtn").style.display = "block"; } else { document.getElementById("myBtn").style.display = "none"; } } scrolling to top - works: topFunction() { document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; } Thank you. where on your code are you calling the scrollFunction() ?? – Teobis Jun 29 at 0:09 ...