javascript - dynamically change header based on angular js partial view -


i know this question identical, implementation needs changed , can't quite work out do.

in answer linked, solution involved using

app.config(['$routeprovider', '$locationprovider', function($routeprovider, $locationprovider) {   $routeprovider.     when('/test1', {template: 'page 1', controller: test1ctrl}) ...  app.factory('page', function(){     var title = 'default';     return {     title: function() { return title; },     settitle: function(newtitle) { title = newtitle; }     }; });  function test1ctrl($scope, page) {   page.settitle('title1'); } ... 

within app.js file. however, , have config of form:

... $routeprovider     .when("/", {       templateurl: "partials/landing.html", controller:"landingctrl"     }) 

with controller landingctrl defined in file, controllers.ts, this:

class landingctrl {     public isfirstplay: any;      constructor($scope) {         $scope.vm = this;         this.isfirstplay = true;     } ... 

so how implement function of form in answer linked layout?

okay took different approach creating dynamic info every view.

.config(function($stateprovider, $urlrouterprovider, $ionicconfigprovider) {  $ionicconfigprovider.views.transition('none');  $stateprovider   .state('login', {  params: 8,  url: "/login",  templateurl: "templates/login.html",  controller: "loginctrl"  })   .state('settings', {    params: 8,    url: '/settings',    templateurl: "templates/settings.html",    controller: "settingsctrl"  }) }); 

basicly every view has own template, controller, url, , params, ofc can define on own.

.state('settings', {   params: {title: put title u want here},   url: '/settings',   templateurl: "templates/settings.html",   controller: "settingsctrl" }) 

with said u can read params in main controller

 $rootscope.$on('$statechangesuccess', function (ev, to, toparams, from, fromparams) {     $rootscope.previousstate = from.name;     $rootscope.currentstate = to.name;     // gets name of current state , sets class in ion-nav-bar!     $scope.statename = $rootscope.currentstate; }); 

in example whereever go know @ state , params state has example title need

i hope helpful


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -