angularjs - access the $routeparam and $stateParam objects with the dot -
i taking me debuge thing can't seem figure out.i think missing basic here. here problem consol.log($stateparams) returns params out in console
energychain: "6"energyid: "1"facilityid: "1"resourceid: "1" when running specific params
consol.log($stateparams.energychain) returns
undfined 6
for link http://localhost:3238/#/resource/1/6/1/1 here either controller excuted 2 times 1 time undefined value 1 time 6 value true or statesparam returning old value variable
here code
var myapp = angular.module('myapp', ['nggrid', "nganimate", "ngaria", 'ngmaterial', "ui.router"]); myapp.config(function ($stateprovider, $urlrouterprovider) { // unmatched url, send /route1 $urlrouterprovider.otherwise("/") $stateprovider .state('firststate', { url: "/resource/:energyid/:energychain/:resourceid/:facilityid", templateurl: "/content/resourcetemplate.html", controller: "detailscontroller" }) }); myapp.controller('detailscontroller', ['$scope', '$stateparams', function ($scope, $stateparams) { console.log($stateparams.energychain); $scope.models = [ { parameter: "power", values: "23", per: "of mega watt", scale: "hundred", unit: "mw", period: "october" }, { parameter: "power", values: "23", per: "of mega watt", scale: "hundred", unit: "mw", period: "september" }, { parameter: "power", values: "23", per: "of mega watt", scale: "hundred", unit: "mw", period: "october" }, { parameter: "power", values: "23", per: "of mega watt", scale: "hundred", unit: "mw", period: "annual" }, { parameter: "power", values: "23", per: "of mega watt", scale: "hundred", unit: "mw", period: "annual" }, { parameter: "power", values: "23", per: "of mega watt", scale: "hundred", unit: "mw", period: "annual" }, { parameter: "power", values: "23", per: "of mega watt", scale: "hundred", unit: "mw", period: "annual" } ]; $scope.years = ['2015', '2014', '2013', '2012', '2011', '2010']; $scope.annuals = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; }]);
but cant access params individually due error
Comments
Post a Comment