angularjs-ng-model

AngularJS. When select have ng-model attribute, ng-selected not working

旧街凉风 提交于 2019-11-26 03:45:07
问题 I\'m trying to set ng-selected in my option element, selected attribute is set to true , but option not selected, When I remove ng-model from select all become working. The question : How to make option selected, when I\'m using the model? Here is my plunker ( selected not working here) My code: var app = angular.module(\"plunker\", []); app.controller(\"TestController\", [\"$scope\", function($scope) { $scope.test = 1; $scope.array = [ {\"id\": 1, \"name\": \"first\"}, {\"id\": 2, \"name\":

Difficulty with ng-model, ng-repeat, and inputs

爱⌒轻易说出口 提交于 2019-11-26 03:24:31
问题 I am trying to allow the user to edit a list of items by using ngRepeat and ngModel . (See this fiddle.) However, both approaches I\'ve tried lead to bizarre behavior: one doesn\'t update the model, and the other blurs the form on each keydown. Am I doing something wrong here? Is this not a supported use case? Here is the code from the fiddle, copied for convenience: <html ng-app> <head> <link href=\"//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css\" rel=\

filters on ng-model in an input

℡╲_俬逩灬. 提交于 2019-11-26 01:48:48
问题 I have a text input and I don\'t want to allow users to use spaces, and everything typed will be turned into lowercase. I know I\'m not allowed to use filters on ng-model eg. ng-model=\'tags | lowercase | no_spaces\' I looked at creating my own directive but adding functions to $parsers and $formatters didn\'t update the input, only other elements that had ng-model on it. How can I change the input of that I\'m currently typing in? I\'m essentially trying to create the \'tags\' feature that

AngularJS: ng-model not binding to ng-checked for checkboxes

情到浓时终转凉″ 提交于 2019-11-26 01:24:43
问题 I referred to this before asking this question. AngularJs doesn't bind ng-checked with ng-model If ng-checked is evaluated to true on the html side, the ng-model is not updated. I can\'t ng-repeat as suggested in the above question because I have to use some styling for each checkbox. Here is the plunker that I have created to illustrate my problem. http://plnkr.co/edit/YsOsPh3vjkPMUUDa6r2t To see what I want, please open the console, and just click on Submit button. Please don\'t check any

Difficulty with ng-model, ng-repeat, and inputs

若如初见. 提交于 2019-11-26 00:09:15
I am trying to allow the user to edit a list of items by using ngRepeat and ngModel . ( See this fiddle .) However, both approaches I've tried lead to bizarre behavior: one doesn't update the model, and the other blurs the form on each keydown. Am I doing something wrong here? Is this not a supported use case? Here is the code from the fiddle, copied for convenience: <html ng-app> <head> <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet"> </head> <body ng-init="names = ['Sam', 'Harry', 'Sally']"> <h1>Fun with Fields and ngModel</h1>

ng-model for `<input type=“file”/>` (with directive DEMO)

≯℡__Kan透↙ 提交于 2019-11-25 23:57:05
问题 I tried to use ng-model on input tag with type file: <input type=\"file\" ng-model=\"vm.uploadme\" /> But after selecting a file, in controller, $scope.vm.uploadme is still undefined. How do I get the selected file in my controller? 回答1: I created a workaround with directive: .directive("fileread", [function () { return { scope: { fileread: "=" }, link: function (scope, element, attributes) { element.bind("change", function (changeEvent) { var reader = new FileReader(); reader.onload =