angularjs - Why isn't my view updating when changing the model of different directive scopes but bounded (what appears to be) correctly? -


i created plunkr problem:

http://plnkr.co/edit/t2884mo6su9mv5xdqmnu?p=preview

what i'm trying create directive goes in text box , makes suggestions type. typeahead widget of angularui team. don't use theirs because need more features in component.

now, code consists in module has 2 directives. "typeahead" , "popup". problem when update model linking function of typeahead, changes don't reflected on popup until clicked. scopes seem fine, view, doesn't rendered.

the test this:

  1. focus text box.
  2. blur it.
  3. click on gray box. - log gets updated should have in step 1 , 2.
  4. click 1 of items of list. - log gets updated
  5. focus , blur text box - log gets updated, view doesn't.
  6. click on gray box. - log shows happened in step 5.

what i'm doing wrong? should take control on digest cycle? wouldn't know how.

additional information (you may skip this): further features i'm after showing modal dialog when user wants create or edit record on list. consist in quite lot of inputs i'm thinking in putting edit button in each record , create button inside text box. items in list bounded records in database , heavily used throughout app.

you don't need "take on digest cycle", need trigger run since you're binding events outside of angular context.

just use scope.$apply:

scope.$apply(function(){     scope.test.changingtext += "focused\n"; }); 

fork of plunker

$apply docs


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -