function clsEjemplo(nombre, desc, url) {
this.nombre = nombre;
this.descripcion = desc;
this.url = url;
this.color = '';
}
function clsCategoriaEjemplo(nombre, descripcion) {
this.nombre = nombre;
this.descripcion = descripcion;
this.elementos = [];
}
// Controlador Angular
function EjemplosCtrl($scope) {
$scope.ejemplos = [];
var categoriaPlantillas = new clsCategoriaEjemplo("Plantillas",
"Plantillas Básicas");
// Añadimos cada uno de los ejemplos por categoría
var ejemplo1 = new clsEjemplo('xx', '', 'www.google.es');
//ejemplo1.color = randomColor();
categoriaPlantillas.elementos.push(ejemplo1);
var ejemplo2 = new clsEjemplo('xx', '', 'www.jsfiddle.net');
categoriaPlantillas.elementos.push(ejemplo2);
// Añadimos la categoría al array de ejemplos
$scope.ejemplos.push(categoriaPlantillas);
var categoriaBasicosJavascript = new clsCategoriaEjemplo("Javascript Básicos",
"Básicos de Javascript: mínimo, máximo..");
var ejemplo3 = new clsEjemplo('xx', '', 'www.jsfiddle.net');
categoriaBasicosJavascript.elementos.push(ejemplo3);
// Añadimos la categoría al array de ejemplos
$scope.ejemplos.push(categoriaBasicosJavascript);
$scope.randomColor = function () {
// Declaramos el array con colores
var colores = ['#409da5',
'#da8515',
'#4849a6',
'#cd432d',
'#228b22',
'#f0f204'];
// Generamos un número aleatorio entre 0 y 5
var rand = Math.floor((Math.random() * 5));
return "color" + rand;
};
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.