国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

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

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

問題描述

demo功能描述:在一個頁面中實現學生信息瀏覽的功能。首先,以列表的方式顯示全部學生的姓名;然后,當在列表單擊某個學生姓名時,進入改學生的詳細資料頁。顯示該學生的全部資料。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://m.cgvv.com.cn/bower_components/angular/angular.min.js'></script> <script type='text/javascript' src='http://m.cgvv.com.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>瀏覽學生信息的主頁</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://m.cgvv.com.cn/wenda/14218.html#view/:id'>{{stu.name}}</a></p>

5-7-2.html

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

操作步驟:1.先打開5-7.html2.點擊學生姓名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?

這是什么原因導致的,會是這句的問題嗎?href='http://m.cgvv.com.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){

相關文章:
主站蜘蛛池模板: 萌白酱喷水福利视频在线 | 国产色司机在线视频免费观看 | 亚洲bt欧美bt国产bt | 最新亚洲人成网站在线影院 | 美女视频免费看视频网站 | 波多结衣一区二区三区 | 亚洲第一看片 | 欧美日一区| 成人区精品一区二区不卡亚洲 | 亚洲欧美日韩国产综合高清 | 日本理论片午夜论片 | 午夜宅男在线永远免费观看网 | 97在线观看完整免费 | 欧美成人免费午夜影视 | 美女被免费网站在线视频软件 | 波多野结衣在线视频观看 | 一区二区三区在线播放视频 | 99久久国产综合精品1尤物 | 高清性色生活片欧美在线 | 日韩欧美一区二区中文字幕 | 美女视频黄a全部免费专区一 | 欧美亚洲日本韩国一级毛片 | 亚洲第一影院 | 99视频免费在线 | 一级特黄爽大片刺激 | 亚洲视频播放 | 成人在线免费看 | 自拍视频在线观看视频精品 | 九九热视频在线播放 | 欧美高清强视频 | 毛片大全在线 | 337p粉嫩大胆噜噜噜鲁 | 久久精品国产只有精品2020 | 天堂视频免费看 | 欧美高清色视频在线播放 | 国产成人精品一区二三区2022 | 国产成人免费不卡在线观看 | 日本三级韩国三级在线观看a级 | 免费亚洲网站 | 欧美一级纶理片免费 | 日韩精品在线一区二区 |