2016-09-16 9 views
0

の 'ID_of_element' 私は角度ngRouteのJsはTypeError:プロパティを読み取ることができません未定義

angular.js:13920 TypeError: Cannot read property '103' of undefined 

103このエラーが発生しているが、私の要素

のIDであると私のコードはapp.js

var app = angular.module('myApp',['ngRoute','ngAnimate']); 

app.config(function($routeProvider) { 
    $routeProvider 
    .when("/", { 
     templateUrl : "home.html" 
    }). 
    when("/quatre/:id",{ 
    templateUrl:'quatre.html',controller:'ViewIdInformation'}). 
    when("/404", { 
     templateUrl : "404.html" 
    }) 
    .otherwise({ 
     redirectTo:'/404' 
    }); 
}); 

app.controller('ViewIdInformation',['$scope','$routeParams',function($scope,$routeParams){ 
    $scope.x = $scope.myWelcome[$routeParams.id]; 
}]); 
です

と私のページquatre.htmlのコードはこのようなものです

{{x.id}} 

しかし、私は同じ問題が何か助けてください。

+0

あなたの '$ scope.myWelcome'が定義されていないようである見つけるのstackoverflow感謝します。 '$ routeParams.id'は値が' 103'のようです。鐘を鳴らす? – Paritosh

答えて

0

はあなたが私は解決策がこの

app.controller('ViewIdInformation',['$scope','$routeParams',function($scope,$routeParams){ 

          $scope.id = $routeParams.id; 
関連する問題