angular-ngmodel

Angularjs - set view value is not updating display

删除回忆录丶 提交于 2020-01-03 09:05:31
问题 I got an input directive that should allow users to undo. Enter saves the value using some function, Esc Cancel edits from the last save. For the Esc keypress event i'm using ngmodel.$setViewValue(scope.last_saved_value) but the input is not updating . I know from the docs that this function does not trigger $digest so i put it in an $apply but it is still not working. JSBIN example 回答1: I usually both include and require the ngModel : app.directive('cancelableInput', function($timeout) {

Angularjs - set view value is not updating display

喜夏-厌秋 提交于 2020-01-03 09:05:04
问题 I got an input directive that should allow users to undo. Enter saves the value using some function, Esc Cancel edits from the last save. For the Esc keypress event i'm using ngmodel.$setViewValue(scope.last_saved_value) but the input is not updating . I know from the docs that this function does not trigger $digest so i put it in an $apply but it is still not working. JSBIN example 回答1: I usually both include and require the ngModel : app.directive('cancelableInput', function($timeout) {

Why is this Angular JS filter removing spaces?

谁说胖子不能爱 提交于 2020-01-03 03:13:10
问题 I'm making a tiny app to learn Angular, and have made a custom filter for text processing. Everything is working fine, except that in cases when my output text has multiple spaces, these get automatically reduced to a single space, which I don't want. The issue is not in the function I've defined, because I'm logging the output, which does not have the problem. HTML: <textarea name="textarea" rows="10" cols="50" ng-model="encodeText" placeholder="Type or paste in a message to encode." ><

How to dynamically add input rows to view and maintain value in angularjs ng-model as array item

耗尽温柔 提交于 2020-01-01 20:01:10
问题 I have a situation where I want the user to dynamically add <input> rows when they want to enter a new item. As shown below, the user clicks the "Add Input Item" button and a new input element is added where the user may add text. I'm trying to associate each input element value to the model $scope.items (an array) in app.js . In my index.html , I load the $scope.items using an ng-repeat . What I do not understand is how I can get each input/row to automatically be added to & managed by the

ngModel with a bind function not working in ng2

泄露秘密 提交于 2020-01-01 08:28:34
问题 If I do in a template of a component something like: <input [(ngModel)]="myProperty"></input> then it works, but if I do it with a function in my component it does not: <input [(ngModel)]="getMyProperty()"></input> Here is the plunkr. Tested on RC6. Why? 回答1: Try this construction <input [ngModel]="getMyProperty()"></input> use only square brackets. 来源: https://stackoverflow.com/questions/39468450/ngmodel-with-a-bind-function-not-working-in-ng2

fetch all values in form using ngModel directive in angular

我们两清 提交于 2019-12-31 07:14:22
问题 I am trying to fetch all the values which are in form using ngModel but some how I am getting only first text boxes values. Not getting textbox values added on click of button. Example: stackblitz html: <form #profileSetUpForm="ngForm" (ngSubmit)="saveData(profileSetUpForm)" class="form "> <div class="row m-0"> <div class="col-lg-12 col-md-12 col-sm-12 col-12 profile-input-label"> Tab Name </div> <div class="col-lg-4 col-md-12 col-sm-12 col-12 mt-top-5"> <input type="text" [(ngModel)]=

ng-options filter by value in another dropdown

只谈情不闲聊 提交于 2019-12-31 02:18:10
问题 This seems to be a really straight forward code, but I cannot figure out why it is not working. I want to filter the 'model' dropdown by selected 'make', Make: <select ng-model="makeng" ng-options="option.display for option in makes"> <option ng-disabled="true" ng-selected="true" value="">Select a make</option> </select> Model: <select ng-model="modelng" ng-options="option.display for option in models | filter:{make:makeng}"> <option ng-disabled="true" ng-selected="true" value="">Select a

Does ng-init watch over change on instantiated property like ng-model does?

老子叫甜甜 提交于 2019-12-30 08:53:11
问题 Does ng-init watch over change on instantiated property like ng-model does? Apparently not, so I set a watch as shown below: app.js var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { $scope.$watch('myProp1', function(newVal, oldVal){ $scope.myProp1 = newVal }) }); html <body ng-controller="MainCtrl"> <input ng-init='myProp="my property"'>{{myProp}}</br> <input ng-init='myProp1="my 1 property"'>{{myProp1}}</br> <input ng-init='myProp11="my 11 property"' ng

Does ng-init watch over change on instantiated property like ng-model does?

空扰寡人 提交于 2019-12-30 08:52:31
问题 Does ng-init watch over change on instantiated property like ng-model does? Apparently not, so I set a watch as shown below: app.js var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { $scope.$watch('myProp1', function(newVal, oldVal){ $scope.myProp1 = newVal }) }); html <body ng-controller="MainCtrl"> <input ng-init='myProp="my property"'>{{myProp}}</br> <input ng-init='myProp1="my 1 property"'>{{myProp1}}</br> <input ng-init='myProp11="my 11 property"' ng

filter in ng-repeat by values?

时间秒杀一切 提交于 2019-12-25 07:59:53
问题 I would like to filter an ng-repeat by a key that has 4 values(1-4) using uib-tabs. Is there a way to do this inline with ng-model on the tab elements? If so, what is the format? For instance, I have an ng-repeat like this: <div ng-repeat="item in reportsData">{{item.name}} - {{item.packageID}}</div> and in my reportsData array I have ..."packageID": 1,... Where packageID can be of a value between 1 and 4. The trick is that I want to setup something along the lines of item.packageID >=1 How