亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

angular.js - angular TypeError: Cannot read property ’id’ of undefined?

瀏覽:72日期:2024-09-28 11:53:53

問題描述

demo功能描述:在一個頁面中實現(xiàn)學(xué)生信息瀏覽的功能。首先,以列表的方式顯示全部學(xué)生的姓名;然后,當(dāng)在列表單擊某個學(xué)生姓名時,進入改學(xué)生的詳細資料頁。顯示該學(xué)生的全部資料。5-7.html

<!DOCTYPE html><html lang='en' ng-app='a5_7'><head> <meta charset='UTF-8'> <title>Title</title> <script type='text/javascript' src='http://www.aoyou183.cn/bower_components/angular/angular.min.js'></script> <script type='text/javascript' src='http://www.aoyou183.cn/bower_components/angular-route/angular-route.min.js'></script> <style>body{ font-size:13px;}.show{ background-color:#cccccc; padding:8px; width:260px; margin:10px 0;} </style></head><body> <h1>瀏覽學(xué)生信息的主頁</h1><p ng-view></p></body><script type='text/javascript'>var a5_7 = angular.module(’a5_7’,[’ngRoute’]); a5_7.controller(’c5_7_1’,[’$scope’, function($scope){$scope.students = students; }]); a5_7.controller(’c5_7_2’,[’$scope’, function($scope,$routeParams){for(var i=0; i<students.length; i++){// console.log(students.student[i]); if(students[i].stuId == $routeParams.id){$scope.student = students[i];break; }} }]); a5_7.config([’$routeProvider’, function($routeProvider){$routeProvider.when(’/’,{ controller:’c5_7_1’, templateUrl:’5-7-1.html’}).when(’/view/:id’,{ controller:’c5_7_2’, templateUrl:’5-7-2.html’, publicAccess:true}).otherwise({ redirectTo:’/’}); }]); var students = [{ stuId:1000, name:’張明明’,sex:’女’,score:60},{ stuId:1001, name:’李清思’,sex:’女’,score:80},{ stuId:1002, name:’劉小華’,sex:’男’,score:90},{ stuId:1003, name:’陳總總’,sex:’男’,score:70} ]</script></html>

5-7-1.html

<p ng-repeat='stu in students' class='show'> <a href='http://www.aoyou183.cn/wenda/14218.html#view/:id'>{{stu.name}}</a></p>

5-7-2.html

<p class='show'> <p>學(xué)號:{{student.stuId}}</p> <p>姓名:{{student.name}}</p> <p>性別:{{student.sex}}</p> <p>分數(shù):{{student.score}}</p></p>

操作步驟:1.先打開5-7.html2.點擊學(xué)生姓名angular.js - angular TypeError: Cannot read property ’id’ of undefined?3.控制臺報錯:

angular.js - angular TypeError: Cannot read property ’id’ of undefined?

angular.js - angular TypeError: Cannot read property ’id’ of undefined?

這是什么原因?qū)е碌模瑫沁@句的問題嗎?href='http://www.aoyou183.cn/wenda/14218.html#view/:id'

問題解答

回答1:

a5_7.controller(’c5_7_2’,[’$scope’, function($scope,$routeParams){//沒有注入$routeParams

請更改為

a5_7.controller(’c5_7_2’,[’$scope’,’$routeParams’, function($scope,$routeParams){

相關(guān)文章:
主站蜘蛛池模板: 六月婷婷精品视频在线观看 | 亚洲精品αv一区二区三区 亚洲精品不卡 | 美女被靠视频免费网站不需要会员 | 日本免费看片在线播放 | 中文精品久久久久国产不卡 | 毛片在线播放观看日本 | 中国女人freexxxx性mp4 | 国产一级淫片a视频免费观看 | 久久精品视频播放 | 1000部羞羞禁止免费观看视频 | 一级特黄aaa大片在线观看视频 | 色视频在线免费观看 | 日韩国产三级 | 看黄色的视频 | 国产久7精品视频 | 国产三级网站 | 一区国严二区亚洲三区 | 久久一区精品 | 亚洲婷婷丁香 | 福利在线一区二区 | 香蕉人精品视频多人免费永久视频 | 欧美一级片网址 | 在线观看www妖精免费福利视频 | 2015xxx小明永久免费 | 日本黄色小视频网站 | 婷婷六月久久综合丁香76 | 麻豆传媒入口直接进入免费版 | 一本伊大人香蕉在线观看 | 国产成人福利在线 | 看一级毛片一区二区三区免费 | a性视频 | 99精品久久秒播无毒不卡 | 蕾丝视频www在线观看 | 美女免费视频一区二区 | 婷婷综合色伊人阁 | 国产免费午夜a无码v视频 | 久久99精品视频在线在线观看 | 国偷盗摄自产福利一区在线 | 国产在线拍偷自揄观看视频网站 | 国语自产偷拍精品视频偷最新 | 一级片一区 |