2016-04-12 23 views
0

Denetleyici için bir açısal projem, app.js ve sonra main.js var. Şey bir yönerge oluşturmak istiyorum ve ben app.js veya main.js'de oluşturup oluşturmama iki farklı hata alıyorum ama iki şekilde çalışmıyor.Yönerge nedenleri oluşturma [ng: areq] hatası

Bu benim app.js (henüz hiçbir direktif)

var myapp = angular 
    .module('nombre_proyectoApp', [ 
    'ngAnimate', 
    'ngCookies', 
    'ngResource', 
    'ngRoute', 
    'ngSanitize', 
    'ngTouch', 
    'ngDialog' 
    ]); 

    myapp.config(function ($routeProvider,$sceDelegateProvider) { 
    $routeProvider 
     .when('/', { 
     templateUrl: 'views/main.html', 
     //templateUrl: '/dms/static/nombre_proyecto/views/main.html', 
     controller: 'MainCtrl', 
     controllerAs: 'main' 
     }) 
     .when('/about', { 
     templateUrl: 'views/about.html', 
     //templateUrl: '/dms/static/nombre_proyecto/views/about.html', 
     controller: 'AboutCtrl', 
     controllerAs: 'about' 
     }) 
     .otherwise({ 
     redirectTo: '/' 
     }); 

    $sceDelegateProvider.resourceUrlWhitelist(['self','http://*.leroymerlin.es/**']); 

    }); 

Ve bu benim main.js (henüz hiçbir direktif)

myapp.controller('MainCtrl', ['$scope','$http','ngDialog','$sce', function ($scope, $http, ngDialog, $sce) { 

    $scope.Math = window.Math; 

    $scope.seleccion = 'all'; 

    $scope.productos = []; 

    $http.get('productos.json').then(function(response){ 
     $scope.productos = response.data;     
    }); 

    $scope.select = function (s){ 
     $scope.seleccion = s; 
    }; 

    }]); 

Şimdi, bu sadece çalışıyor, ama Ve sonra bu hatayı alıyorum bu

myapp.directive('listado', function(){ 

    return { 
     restrict: 'E', 
     compile: function(element, attrs){ 
     var filtro = attrs.filtro || 'all'; 
     var productos = attrs.productos; 
     var htmlText = ' 
      <ul> 
      <li class="producto col-md-12" ng-repeat="producto in '+ productos +'" ng-if="(producto.group == '+ filtro +') || ('+ filtro +' == \'all\')"> 

       <div class="col-md-4"> 
       <img src="{{producto.imgUrl}}" alt="foto"> 
       </div> 

       <div class="col-md-5"> 
       <p class="titulo">{{producto.title}}</p> 
       <p class="verdeLM"><a href="http://www.leroymerlin.es/fp/{{producto.ref}}">Ref. {{producto.ref}}</a></p> 
       <p class="gris">{{producto.description}}</p> 
       </div> 

       <div class="col-md-3 text-right"> 
       <div class="precio">{{Math.floor(producto.price)}},<sup>{{decimales(producto.price)}} &euro;</sup></div> 
       <a class="btnVerProd" href="http://www.leroymerlin.es/fp/{{producto.ref}}" target="_blank" ng-click="verProd(producto.ref)">Ver producto</a> 
       </div> 

      </li> 
      </ul>'; 
     element.replaceWith(htmlText); 
     } 
    }; 

    }); 

gibi main.js içinde yönergesini ekleyin:

angularjs: 13424 Hata: [ng: areq] Değişken 'MainCtrl' Yani http://errors.angularjs.org/1.5.3/ng/areq?p0=MainCtrl&p1=not%20aNaNunction%2C%20got%20undefined

tanımsız var, bir işlev değil, ben app.js koymak deneyin, sonra bu olsun başka hata:

angularjs: 68 Yakalanmayan hatası: [$ enjektör: modulerr] nedeniyle modül nombre_proyectoApp örneklenemedi: hatası: [$ enjektör: nomod] modül 'nombre_proyectoApp' mevcut değildir! Ya modül adını yanlış yazdınız ya da yüklemeyi unutmuşsunuz. Bir modül kaydediyorsanız, bağımlılıkları ikinci argüman olarak belirtin. Herhangi bir yardım çok takdir bu

<listado productos="productos"></listado> 

gibi main.html olarak http://errors.angularjs.org/1.5.3/ $ enjektör/nomod? P0 = nombre_proyectoApp

aradım yönergesi ..

cevap

0

günü ... Sabit Her hatanın en üstünde, herşeyin yanlış gitmesini yasaklayan bir yasadışı kodum vardı.

İlgili konular