angularjs - $viewContentLoading is not working -


i'm trying log value before content gets loaded. i'm using $viewcontentloading purpose getting called inside init function. but, value not getting logged. can what's wrong code.

var app = angular.module('plunker', []);    app.controller('mainctrl', function($rootscope, $timeout, $q) {    function init() {    $rootscope.$on('$viewcontentloading', function(event, viewconfig)  {    alert("hello");    console.log(33)  });  }  init();    });
<!doctype html>  <html ng-app="plunker">      <head>      <meta charset="utf-8" />      <title>angularjs plunker</title>      <link rel="stylesheet" href="style.css" />      <script src="http://code.angularjs.org/1.0.7/angular.min.js" data-semver="1.0.7"></script>      <script src="app.js"></script>    </head>      <body ng-controller="mainctrl">    </body>    </html>

what mean how works. recap:

$viewcontentloading gets broadcasted dependencies under resolve section resolved controller gets instantiated , resolve dependencies injected. $viewcontentloaded emitted. controller reacts $viewcontentloaded (when setup delegate dispatch events of course). i've got views take little while load data server (sometimes ~1 second), wanted show loading indicator while transitioning 1 route another.

i'm aware of other ways render while loading data. if routes responsible of defining ui state putting controller, template, , data coming resolve section, find natural let them notify whoever wants listen it current status of loading process.

my use case

my use case master-detail view drilldown interaction. let's i've got following ui-views set up. detail view child of collection view rendering user names in case.

+-----------------------------------------+ | user 1 | user 1 details view | | user 2 | | | user 3 | | | user 4 | | | user 5 | | | user 6 | | +-----------------------------------------+ maybe i'm missing something, when first point browser #/users/1 ideally i'd expect following happen:

users parent route resolves promises , injects result on controller associated state. collection view gets rendered while users.show still idle getting data sever (this api call takes second load). detail view renders loading indicator. resolve section in users.show gets 200 ok server, injects dependencies in controller. can render user's detail.example


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -