Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Damian Green 452 posts 1433 karma points
    Nov 19, 2014 @ 23:14
    Damian Green

    Odd angular model binding going on

    Quick question on model binding.

    I am buiding a custom dashboard in the backend (based on Tims People tree -

    I am not using a full person object like the example but a simple string that is on my model - searchterm.

    I have textbox and it display the default i set in the model. When i edit the textbox the value on the scope is not updating but if i add a second textbox and set it to the same model variable it updates as i type.

    The only way i have gotten to update the model value on the scope is to add a change event on the textbox, pass in the model value from the view and update the scope!

    Driving me nuts as to why!! Any ideas??

    Here is the bit from the view

     <umb-control-group label="Search Term" description="Enter serach term'">
                        <input type="text" class="umb-editor umb-textstring" ng-model="searchTerm" ng-change="changed(searchTerm)" required />
                        scope = {{ searchTerm}} ..
                        <input ng-model="searchTerm"/>

    Here is the controller:

    function ($scope, $routeParams, memberLocateResource, notificationsService, navigationService) {
        console.log('scope triggered');
        $scope.loaded = false;
        $scope.members = {};
        $scope.searchTerm = "roger";
        $scope.searchType = "AccountNumber";
        if ($ == -1) {
            $scope.searchTerm = "test 2";
            $scope.members = {};
            $scope.loaded = true;
        $scope.loaded = true;
        $scope.searchDone = false;
        $scope.changed = function (val) {
            $scope.searchTerm = val;
            console.log('val=' + val);
            console.log('changed' + $scope.searchTerm);
        $ = function () {
            console.log('search term=' + $scope.searchTerm);
            console.log('search type=' + $scope.searchType);
            memberLocateResource.findByUsername($scope.searchTerm).then(function (response) {
                $scope.members =;
                $scope.memberLocateForm.$dirty = false;
                $scope.searchDone = true;
                //navigationService.syncTree({ tree: 'peopleTree', path: [-1, -1], forceReload: true });
                //notificationsService.success("Success", person.firstName + " " + person.lastName + " has been saved");
  • Dave Woestenborghs 3429 posts 11693 karma points MVP 7x admin c-trib
    Dec 01, 2014 @ 15:20
    Dave Woestenborghs

    You have a error in your view. You have {{ searchTerm}}. This should be {{searchTerm}} without the leading space.


Please Sign in or register to post replies

Write your reply to: