2016-09-16 64 views
0

屬性 'ID_of_element' 我有這個錯誤角ngRoute的js類型錯誤:無法讀取的未定義

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'。 '$ routeParams.id'好像具有值'103'。敲響任何鈴鐺? – Paritosh

回答

0

謝謝計算器我找到的解決方案是這樣的

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

          $scope.id = $routeParams.id; 
相關問題