/ / Model zakresu nie aktualizuje się przy wyborze - angularjs, typeahead.js

Model zakresu nie aktualizuje się przy wyborze - angularjs, typeahead.js

Mam tę metodę w moim kontrolerze:

$scope.selectEscalationResponsible = function($user, $model, $label) {

$scope.escalationResponsible = $user.user.first_name + " " + $user.user.last_name;

};

Ta metoda jest uruchamiana przez ten element wejściowy:

<input class="form-control"
type="text"
ng-model="escalationResponsible"
typeahead-wait-ms="200"
select-text-on-focus
typeahead-editable="false"
typeahead="value as (user.user.first_name + " " + user.user.last_name) for user in oppType.team_settings.users"
typeahead-on-select="selectEscalationResponsible($item, $model, $label)">
<small translate>Start typing a name from the list below</small>

Metoda jest wyzwalana, ponieważ wartość pola wejściowego nie jest aktualizowana. Nie mogę zrozumieć, dlaczego.

Odpowiedzi:

0 dla odpowiedzi № 1

Wszystko wydaje się działać dobrze. Oto plunkr, na który możesz spojrzeć http://plnkr.co/edit/MnGM7ye8VV3jZ9G63RWc?p=preview

angular.module("ui.bootstrap.demo", ["ngAnimate", "ui.bootstrap"]);
angular.module("ui.bootstrap.demo").controller("TypeaheadCtrl", function($scope, $http) {

$scope.users =[{user: {first_name: "test", last_name: "last"}},{user: {first_name: "test2", last_name: "last2"}}];

$scope.selectEscalationResponsible = function($user, $model, $label) {

$scope.escalationResponsible = $user.user.first_name + " " + $user.user.last_name;

};

});





<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular-animate.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.4.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<script type="text/ng-template" id="customTemplate.html">
<a>
<img ng-src="/images/http://upload.wikimedia.org/wikipedia/commons/thumb/{{match.model.flag}}" width="16">
<span bind-html-unsafe="match.label | typeaheadHighlight:query"></span>
</a>
</script>
<div class="container-fluid" ng-controller="TypeaheadCtrl">
<input class="form-control"
type="text"
ng-model="escalationResponsible"
typeahead-wait-ms="200"
select-text-on-focus
typeahead-editable="false"
typeahead="value as (user.user.first_name + " " + user.user.last_name) for user in users"
typeahead-on-select="selectEscalationResponsible($item, $model, $label)">
{{escalationResponsible}}
</div>
</body>
</html>