0

I have a Angularjs form with a list with names. When I click on a name the form will change with here profile. When I change one input and don't save it and I click on a other profile every thing change except the one input that has changed.

<form class="form-horizontal bordered-row" >
                <div class="form-group">
                  <label class="col-sm-4 control-label">Naam</label>
                  <div class="col-sm-6">
                    <input type="text" class="form-control" id="" value="{{gegevens.naam | capitalize}}">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-4 control-label">Categorie</label>
                  <div class="col-sm-6">
                    <select class="form-control">
                      <option ng-repeat="x in producten_categorie" value="{{x.value}}" ng-selected="gegevens.categorie == x.value">{{x.name}}</option>
                    </select>
                  </div>
                </div>
                <div class="form-group pad25L">
                  <button class="btn btn-info" ng-click="productAlgemeen_update(gegevens.naam);">Save</button>
                </div>
              </form>

And the change scope:

$scope.productGegevens = function(product){
$http.post("php/producten-locatie.php", {'id':product.id}).then(function(response){
  $scope.producten_locatie = response.data.records[0];
  $scope.gegevens = {
    id:product.id,
    naam:product.naam,
    categorie:product.categorie,
    straatnaam:$scope.producten_locatie.straatnaam,
    huisnummer:$scope.producten_locatie.huisnummer,
    postcode:$scope.producten_locatie.postcode,
    stadsnaam:$scope.producten_locatie.stadsnaam
  };
});

}

6
  • It looks like change detection is a problem. Can you share you ts class file Commented Sep 27, 2017 at 11:51
  • @AniruddhaDas I'm new in Angular, but what is ts class file? Everything will change when I press de change scope but except the one has changed, maybe because it is dirty? Commented Sep 27, 2017 at 11:52
  • Never mind I was thinking it's angular application but it angularjs. Commented Sep 27, 2017 at 11:54
  • @AniruddhaDas Sorry Commented Sep 27, 2017 at 11:55
  • you mean to say the changed value remains same and not reflecting correct value when we open other profile ? Commented Sep 27, 2017 at 11:58

1 Answer 1

1

Please note that input data needs to bind with ng-model whereas you are entering your input with value tag. it means the value is rendered in html not in model, so when you click on other profile UI can not detect the change. Please use ng-model for input value not value tag of input box.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.