Hi,
I have develop a angular app that receives some json and presents it as
charts.
My problem is that i have all the code (html) in the same file and i want
to split it and since i'm using jquery tabs i thought that each tab should
be a view.
I have been checking ngRoute to use with ng-view but i don't know how to
implement it in my app.
I'm also using nvd3 and d3 for the charts part and one of my questions is
does a single controller works for all the views?
Thk
This is my code:
/* Application */
var dashboardApp = angular.module("dashboardApp", ['nvd3ChartDirectives',
'dashboardServices']);
/* Service */
var dashboardServices = angular.module('dashboardServices', ['ngResource']);
dashboardServices.factory('Dash', ['$resource',
function ($resource) {
return $resource('http://localhost:9000/json', {}, {
query: {
method: 'GET',
isArray: true
}
});
}
]);
/* Controller */
function DashboardCtrl($scope, Dash) {
$scope.xFunction = function () { return function (d) { return d.key; };
};
$scope.yFunction = function () { return function (d) { return d.y; }; };
$scope.graficos = [];
Dash.query(function (data) {
var a = 0;
for (var j = 0; j < data.length; j++) { //nº de sectores
for (var i = 0; i < data[j].values.length; i++) { //nº de
graficos em cada sector
$scope.graficos[a] = [];
for (var x = 0; x < data[j].values[i].chartData.length;
x++) //valores de cada grafico
$scope.graficos[a][x] = data[j].values[i].chartData[x];
a++;
}
}
if (data[data.length - 1].key == "Comparativo") {
$("ul").find("li").attr("style", "");
/*Bar Charts*/
$("div.DivRight").attr("class", "HiddenDivRight");
$("div.DivRightCima").attr("class", "HiddenDivRightCima");
$("div.DivRightBaixo").attr("class", "HiddenDivRightBaixo");
$("div.DivRightPanel").attr("class", "HiddenDivRightPanel");
/*Pie Charts*/
$("div.DivCentral").attr("class", "HiddenDivCentral");
$("div.DivCentralRight").attr("class", "HiddenDivCentralRight");
$("div.DivCentralLeft").attr("class", "HiddenDivCentralLeft");
$("div.DivCentralBaixo").attr("class", "HiddenDivCentralBaixo");
$("div.DivCentralPanel").attr("class", "HiddenDivCentralPanel");
$("div.LeftPieChart").attr("class", "HiddenLeftPieChart");
$("div.RightPieChart").attr("class", "HiddenRightPieChart");
}
});
}
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.