Changes between Version 2 and Version 3 of DeveloperGuidelines/EdenMobile/Routing

03/30/17 11:59:11 (7 years ago)
Dominic König



  • DeveloperGuidelines/EdenMobile/Routing

    v2 v3  
    4343The role of controllers and views is equivalent to controllers/views in the Sahana Eden web application.
    45 The view template is rendered once when the state is entered the first time (unless reloading is enforced in $state.go), and the state controller executed every time when the state is entered.
     45The view template is rendered, and the state controller executed when the state is first entered (unless reloading is enforced in $state.go, then both would be reloaded).
     47Unlike Sahana Eden view templates, though, placeholders in EdenMobile views are updated whenever the corresponding {{{$scope}}} attribute changes, e.g. a template
     50<!-- in the view: -->
     54...would replace the ''title'' placeholder with the value of {{{$scope.title}}}, similar to Sahana Eden views. But when the controller later changes {{{$scope.title}}} (e.g. in response to an event):
     57// in the controller:
     58$scope.title = 'Something Else';
     61...then this will also update the view (instantly, more or less).
     63Equally, view elements (e.g. inputs) can be bound to {{{$scope}}} attributes (using the {{{ng-model}}} directive), so that every change of the input value will be reflected instantly in the {{{$scope}}}, thereby making it available for the controller:
     66<!-- in the view: -->
     67<input type="text" ng-model="firstName"/>
     70...can be accessed as:
     72// in the controller:
     73var firstName = $scope.firstName;
     76Besides data, the {{{$scope}}} object can also hold functions:
     79// in the controller:
     80$scope.buttonClicked = function() {
     81  // Do something
     85...which can then e.g. be used in the view as event handlers:
     88<!-- in the view -->
     89<button type="button" ng-click="buttonClicked()"/>
    4792State controllers live in the www/controllers folder, and view templates in www/views.