2015-08-07 6 views
0

У меня есть два .factory с массивом каждого, но бросает мне ошибку второй .factory, походит на не может иметь два .factoryДва .factory ошибки (angularjs + ионные)

Любой помощь, пожалуйста,

Спасибо

.factory('RawData', function() { 
    // Might use a resource here that returns a JSON array 

    // Some fake testing data 
    var rawData = [{ 
     "id": "1", 
     "tipo": "evento", 
     "titulo": "Esta es una noticia de dos líneas principal", 
     "bg": "fondo-not.png", 
     "bgdetail": "noti-detalle.png", 
     "fec": "ABRIL, 14, 2:56 AM", 
     "com": "Backpack from Très Bien. Made in collaboration with Haerfest. Nylon body with top zip closure. Leather bottom. Outer compartment with zip closure and leather trims. Adjustable shoulder straps in leather. Metal hardware. Lined with cotton. Inner compartments. Outer logo branding." 
    }]; 

    return { 
     all: function() { 
      return rawData; 
     }, 
     get: function(id) {   
      for (var i = 0; i < rawData.length; i++) { 

       if (parseInt(rawData[i].id) === parseInt(id)) { 
        return rawData[i];         
       } 
      }   
      return null; 
     } 
    }; 
}); 

.factory('ServicioData', function() { 
    // Might use a resource here that returns a JSON array 

    // Some fake testing data 
    var servData = [{ 
     "id": "1", 
     "logo": "logo1.png", 
     "titulo": "Restaurante",  
     "com": "Nuestro Menú" 
    }]; 

    return { 
     all: function() { 
      return servData; 
     }, 
     get: function(id) {   
      for (var i = 0; i < servData.length; i++) { 

       if (parseInt(servData[i].id) === parseInt(id)) { 
        return servData[i];         
       } 
      }   
      return null; 
     } 
    }; 
}); 

Ошибка:

Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to: Error: [$injector:nomod] Module 'starter' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.3.13/ $injector/nomod?p0=starter at REGEX_STRING_REGEXP (http://localhost/ionic/www/lib/ionic/js/ionic.bundle.js:8346:12) at http://localhost/ionic/www/lib/ionic/js/ionic.bundle.js:10050:17 at ensure (http://localhost/ionic/www/lib/ionic/js/ionic.bundle.js:9974:38) at module (http://localhost/ionic/www/lib/ionic/js/ionic.bundle.js:10048:14) at http://localhost/ionic/www/lib/ionic/js/ionic.bundle.js:12380:22 at forEach (http://localhost/ionic/www/lib/ionic/js/ionic.bundle.js:8606:20) at loadModules (http://localhost/ionic/www/lib/ionic/js/ionic.bundle.js:12364:5) at createInjector (http://localhost/ionic/www/lib/ionic/js/ionic.bundle.js:12290:11) at doBootstrap (http://localhost/ionic/www/lib/ionic/js/ionic.bundle.js:9728:20) at bootstrap (http://localhost/ionic/www/lib/ionic/js/ionic.bundle.js:9749:12) http://errors.angularjs.org/1.3.13/ $injector/modulerr?p0=starter&p1=Error%3…2Flocalhost%2Fionic%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A9749%3A12)

+0

Показать, где вы регистрируете модуль "стартера", то есть 'angular.module ("стартер", [...])' –

ответ

1

удалить; после окончания первой фабрики, чтобы вы могли продолжить цепочку второго.

.factory('RawData', function() { 
    // Might use a resource here that returns a JSON array 

    // Some fake testing data 
    var rawData = [{ 
     "id": "1", 
     "tipo": "evento", 
     "titulo": "Esta es una noticia de dos líneas principal", 
     "bg": "fondo-not.png", 
     "bgdetail": "noti-detalle.png", 
     "fec": "ABRIL, 14, 2:56 AM", 
     "com": "Backpack from Très Bien. Made in collaboration with Haerfest. Nylon body with top zip closure. Leather bottom. Outer compartment with zip closure and leather trims. Adjustable shoulder straps in leather. Metal hardware. Lined with cotton. Inner compartments. Outer logo branding." 
    }]; 

    return { 
     all: function() { 
      return rawData; 
     }, 
     get: function(id) {   
      for (var i = 0; i < rawData.length; i++) { 

       if (parseInt(rawData[i].id) === parseInt(id)) { 
        return rawData[i];         
       } 
      }   
      return null; 
     } 
    }; 
}) 

.factory('ServicioData', function() { 
    // Might use a resource here that returns a JSON array 

    // Some fake testing data 
    var servData = [{ 
     "id": "1", 
     "logo": "logo1.png", 
     "titulo": "Restaurante",  
     "com": "Nuestro Menú" 
    }]; 

    return { 
     all: function() { 
      return servData; 
     }, 
     get: function(id) {   
      for (var i = 0; i < servData.length; i++) { 

       if (parseInt(servData[i].id) === parseInt(id)) { 
        return servData[i];         
       } 
      }   
      return null; 
     } 
    }; 
}); 
+0

спасибо, его работа отлично – user3810167