javascript - Angularjs two-way data binding not working; $watch doesn't work either -


as new angular developer, went through few tutorials , built few stand-alone or firebased angular practice apps, , thought getting handle on framework. wanted start real app paired server , database, found laravel powered angular stack on github:

https://github.com/jadjoubran/laravel5-angular-material-starter

to make long story short, code generated stack angular controllers looks foreign angular i've seen:

class createstringformcontroller{     constructor(){         'nginject';         //     } } 

i added

class createstringformcontroller{     constructor($scope){         'nginject';         $scope.string = 'test';         $scope.stringed = $scope.string+'ed';          //     } } 

and template:

<textarea rows="4" columns="50" class="form-control">{{string}}</textarea> <h3>parsed string: <span>{{stringed}}</span></h3> 

the idea here when type in text area, h3 below outputs value of textarea+'ed' data binding not working. on page load variables set 'test' , 'tested' should be, typing doesn't update value of {{stringed}}. if ditch in controller , put both textarea , h3 same {{string}} doesn't work.

if wrap things in $scope.$watch "$digest running" error. if point me in right direction, rock. also, if explain why stack using constructor instead of app.controller() angularjs tutorials do, , using literally dozens of export/imports, icing on cake!

ps files .js, not .ts, not know typescript is, has come lot in googling.

hope question isn't overly complicated! thanks!

ok, try in template:

<textarea rows="4" columns="50" class="form-control" ng-model="string"></textarea> 

same <span>

<h3>parsed string: <span ng-bind="stringed"></span></h3> 

using {{string}} & {{stringed}} displays value, doesn't bind it.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -