angular-ngmodel

searchKeyword not working in AngularJS filter

℡╲_俬逩灬. 提交于 2019-12-12 00:30:02
问题 I am writing an app using AngularJS on the front end. I want to search through a table by any word/field; one search box for everything. According to this article here: http://hello-angularjs.appspot.com/searchtable I can use filter: searchKeyword to do just this. This is my code, and it is not working as expected. <label>Search: <input ng-model="searchKeyword"></label> <table ng-repeat="post in posts | orderBy: sort | filter: searchKeyword"> <tr> <td> {{index(post)}} </td> <td> {{post.title}

AngularJs ng-model bind from json

試著忘記壹切 提交于 2019-12-12 00:25:43
问题 I have following dropdown: <h3>Selectize theme</h3> <p>Selected: {{produk.category}}</p> <ui-select ng-model="produk.category" theme="selectize" ng-disabled="disabled" style="width: 300px;"> <ui-select-match >{{$select.selected.name}}</ui-select-match> <ui-select-choices repeat="cat in categories | filter: $select.search"> <span ng-bind-html="cat.name | highlight: $select.search"></span> </ui-select-choices> </ui-select> In angular I get a data in json format: $scope.getProductToEdit =

Editing a Form in Angular

泪湿孤枕 提交于 2019-12-11 22:57:25
问题 Please help!! I am finding it very difficult to edit a form. I working with reactive form and adding data to the form and sending to the database works very well. Now I want to query the data in the database so I can edit it and send it again. The data is gotten from the database in form of a json object, I have tried to assign it to a form Group variable so I can display the data in the form and send it but I get errors. I Have also tried displaying the data with the template driven form. It

Remove duplicate attribute(ngModel, value) in angular forms

橙三吉。 提交于 2019-12-11 13:03:03
问题 I have made a DatePickerDirective which is working fine as required. But in order to sync the value of the particular input field on which this directive sits, I have to use value and ngModel attribute both. I wish to use only ngModel how can this be achieved gracefully. Form Element <input appDatePicker type="text" required name="title" value="{{holiday.off_date}}" [(ngModel)]="holiday.off_date" class="form-control" placeholder="01/01/2018"> Component File export class HolidayCreateComponent

Use ng-model in nested Angularjs controller

孤街醉人 提交于 2019-12-11 12:54:39
问题 I have two nested controller in angularjs, and want to use ng-model from outer in inner controller. Suppose this <div ng-controller='outController'> // data.Name : from outer controller <div ng-controller='innerController'> <input type="text" ng-model='name' ng-init='name=data.Name'> {{data.Name}} // display this scope value </div> </div> data.Name value display in html page but not bind to name ng-model. How to bind this value to inner ng-model? 回答1: You should follow dot rule in this case,

Model does not persist using uib-typeahead with ng-repeat

余生长醉 提交于 2019-12-11 10:48:15
问题 I am trying to use uib-typeahead to select one or more objects (via an ng-repeat ), but facing an issue where the model does not persist when adding another object. This is reproduced on Plnkr here (based on ui-bootstrap's demo). (Reproduce the error by selecting a state, then clicking "Select another". The previously selected state disappears!) What is causing the model to not persist? How can this be fixed? Is it an issue with uib-typeahead ? Or the ng-repeat scope? NB: I am also using a

Angular: Reset input value to previous value

不想你离开。 提交于 2019-12-11 08:40:01
问题 In Angular 2+, is it possible to reset value of an input to its previous value programmatically? I have 'Select' dropdown, whereupon selecting a value I need to reset its value to the previous one, if certain validation fails. How can I achieve the same using ngModel (Template form) and formControl (Reactive Form)? (Just need to know if its possible by both the approaches). I have figured out that if we place the ngModelChange event before the ngModel in the select tag in the template, the in

How to store the value of model in a variable?

筅森魡賤 提交于 2019-12-11 08:29:51
问题 I am creating a directive, in which i want to compare the value stored in a model (say "name" as model and it is having value "Angular") to be stored in a variable. I tried something like below, var nameValue=name; but it(nameValue) is not having the value "Angular" Example: app.directive('kmRadio', function() { return{ restrict:'E', compile: function(element,attrs) { var model=ngModelName; console.info(attrs.kmModel); console.info("{{'+attrs.kmModel+'}}"); if(attrs.kmTitle==model) {

Change scope value on ng-click

前提是你 提交于 2019-12-11 06:04:41
问题 I would like to use tabs to hide and show items in an ng-repeat. Is it possible to change the value of a scope like so? <a ng-click="packageType = '1'">Package 1</a><a ng-click="packageType ='2'">Package 2</a><a ng-click="packageType = '3'">Package 3</a> <div ng-repeat="item in packages" ng-show="packageType >=item.packageID"> {{item.name}}</div> and the scope: $scope.packages = [...{ "name": "some name", "packageID": 1}...] Where packageID can be 1, 2 or 3? 回答1: Here's the code that does

ng-model is getting wrong value from dropdown

寵の児 提交于 2019-12-11 04:03:19
问题 My ng-model is updated with the first value when typing in a dropdown when some values SHARE start letters at captions. <div ng-app="dropDown" ng-controller="dropDownController"> <select name="StateId" ng-model="selectedState" class="form-control" ng-change="selectedStateChanged()" ng-options="(states.Abbrev + ' - ' + states.Name) for states in states"></select> <span>{{selectedState.Name||''}}</span> </div> Plnkr http://plnkr.co/edit/pLVzK18iJxrmrL9Oiw4b?p=preview Scenario to test: Click on