You can remove .selected
from saveUsername
in your checkbox input since saveUsername is a boolean. Instead of [(ngModel)]
use [checked]="saveUsername" (change)="saveUsername = !saveUsername"
Edit: Correct Solution:
<input type="checkbox" [checked]="saveUsername" (change)="saveUsername = !saveUsername"/>
Update: Like @newman noticed when ngModel
is used in a form it won’t work. However, you should use [ngModelOptions]
attribute like (tested in Angular 7):
<input type="checkbox" [(ngModel)]="saveUsername" [ngModelOptions]="{standalone: true}"/> `
I also created an example at Stackblitz: https://stackblitz.com/edit/angular-abelrm
Related Posts:
- Angular, image not found (GET 404)
- How to style a checkbox using CSS
- forbidden 403 on image URLS
- Angular: mat-form-field must contain a MatFormFieldControl
- (change) vs (ngModelChange) in angular
- Get checkbox value in jQuery
- How to read if a checkbox is checked in PHP?
- Binding select element to object in Angular
- Can HTML checkboxes be set to readonly?
- jQuery checkbox event handling
- Open source social media icons to download and use on website? [closed]
- CSS calc width and height values
- CSS Background Opacity [duplicate]
- Difference between Constructor and ngOnInit
- How to create an HTML button that acts like a link
- What does In html mean
- Center image horizontally within a div
- Remove CSS class from element with JavaScript (no jQuery) [duplicate]
- How to get a tab character?
- How to make JavaScript execute after page load?
- Is there an upside down caret character?
- Prevent line-break of span element
- How to align iframe always in the center
- Stop floating divs from wrapping
- How can I get the values of data attributes in JavaScript code?
- Disable Scrolling on Body
- Darken CSS background image?
- Alternative to iFrames with HTML5
- Responsive image map
- How to wrap text around an image using HTML/CSS
- javascript close current window
- How to darken a CSS background image?
- How can I create a marquee effect?
- What is “X-Content-Type-Options=nosniff”?
- TypeScript-‘s Angular Framework Error – “There is no directive with exportAs set to ngForm”
- How to download HTTP directory with all files and sub-directories as they appear on the online files/folders list?
- How to set Helvetica font?
- How to make an input type=button act like a hyperlink and redirect using a get request?
- What is ViewChild in Angular2?
- Resize image with javascript canvas (smoothly)
- Including external HTML file to another HTML file [duplicate]
- CSS list-style-image size
- How can I override Bootstrap CSS styles?
- Can’t fix: ‘og:image’ property should be explicitly provided, even if a value can be inferred from other tags
- How to disable auto-play for local video in iframe
- Styling an input type=”file” button
- How to stick footer to bottom (not fixed) even with scrolling
- How to semantically add heading to a list
- Multiple distinct pages in one HTML file
- How to change the background-color of jumbrotron?
- JavaScript: Get image dimensions
- What replaces cellpadding, cellspacing, valign, and align in HTML5 tables?
- How to display a gif fullscreen for a webpage background?
- Padding a table row
- Implement session storage in an Angular 8 application
- Can’t bind to ‘routerLink’ since it isn’t a known property
- How to align 3 divs (left/center/right) inside another div?
- Align an element to bottom with flexbox
- How can I change the thickness of my
tag - How do I horizontally center a table in Bootstrap
- How do I center text in a span?
- text-align justify not working
- Best way to center a on a page vertically and horizontally?
- Find out whether radio button is checked with JQuery?
- Display text on MouseOver for image in html
- How to make a div 100% height of the browser window
- How to resize an image to fit in the browser window?
- How to access and download a file from a server using HTML 5
- How do I install Angular 2 using NPM?
- Display text on MouseOver for image in html
- Layout a flex box similar to a table?
- html : iframe not showing content in html
- How can I capture the right-click event in JavaScript?
- In which directory do I find the HTML file of my wordpress pages?
- How can I publish Word files to a WordPress blog without losing the footnotes?
- Preserve white-space in Page
- How do we remove mystical [X] from text? Image included
- Remove html markup by wordpress
- How can I set different html lang attribute for different countries?
- Add Attribute to p Tag of Post Content
- custom html in page change in browser
- Add Adsense to a website but the server responds with error 510 [closed]
- Can’t save any WordPress post with the html tag in it
- remove string: ‘custom content…’ from every page
- Whitespace Before Doctype
- html entities occur in the_excerpt used as meta description
- Allow Access To Subfolder Of HTML For Logged In Visitors
- Removing Line Break Tags from a Page
- Insert data through a script directly in the db
- Using Tags Instead of Categories for site structure
- Use Mail-Tag from Contac Form 7 in a script
- Line break before headings () appears from nowhere
- Tidy HTML formatting in Gutenberg HTML blocks
- Unable to autoplay and loop a cinemagraph from Imgur
- standard callback function for wp_list_comments
- How to replace a specific html tag in bulk?
- Inserting code into a page just shows raw HTML
- How can I insert a disclaimer in a WordPress site?
- WordPress adds ‘noindex’ tag to search results. Anything I can do about it?
- How can we get Buddypress to interpret HTML entities correctly?