Angularjs:TypeError:无法读取undefined的属性'$ id'

时间:2016-02-23 13:12:53

标签: javascript angularjs node.js

我是angularjs的初学者,我正在使用扩展名AngularJS Batarang。

我在我的控制台中遇到了这个错误:

TypeError: Cannot read property '$id' of undefined

这是我的代码:

index.jade

doctype html
html
  header
    title HELLO - CV
    script(src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js")
    link(rel='stylesheet', href='/stylesheets/style.css')
    link(rel='stylesheet', href='/stylesheets/responsive.css')
    link(rel='stylesheet', href='/stylesheets/animate.min.css')
    meta(name='viewport', content='width=device-width, user-scalable=no')
    script(src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js')
    link(rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.min.css')
    link(href='https://fonts.googleapis.com/css?family=Arimo', rel='stylesheet', type='text/css')
    //script(src='script/viewport.js')
    //script(src='script/index.js')
    script(src='script/controllers.js')

  body(ng-app='appCv')
  header(ng-controller='HeaderController')
      .container
        #content
        h3.post-logo {{postlogo}}
        h1.post-behind {{postbehind}} 
        h2.title {{title1}}
        h2.title {{title2}}

  // Section profile 
  //ngController : directive permettant d'attacher un contrôleur à la vue
    section(ng-controller='Section1Controller')
      .container
        h3.section {{titresection}}
        .line-section
        .section-thumb
            //(img ng-src="{{ image }}")
         p.section

Controllers.js

var appCv=angular.module('appCv',[]);

appCv.controller("HeaderController", function($scope,$log){

    $scope.postlogo="test1";
    $scope.postbehind="test12";
    $scope.title1="test13";
    $scope.title2="test14";

});

appCv.controller("Section1Controller", function($scope,$log){
    $scope.image='./img/avatar.jpg';
    $scope.titresection="Développeur frontend & backend";
});

appCv.directive('showImage', function() {
    return {
        restrict: 'AE',
            replace: 'true',
            templates: '<img ng-src="{{ image }}">'
        };
});

0 个答案:

没有答案