2015-09-17 6 views
0

У меня есть этот метод в моем контроллере:Scope модель не обновляется при выборе

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

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

    }; 

Этот метод вызывают слова этого входного элемента:

<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> 

метод срабатывает, на значение поля ввода не обновляется. Я не могу понять, почему.

ответ

0

Все, кажется, работает нормально. Вот plunkr для вас, чтобы посмотреть 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="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> 
+0

Я вижу, что ваш пример работает, но он просто не работает в моем конце. – Repox

+0

Вы можете создать plunkr? –

+0

Я не знаю, что не получится. По какой-то причине мой код работает сейчас. – Repox

Смежные вопросы