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

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

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

瀏覽:75日期: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://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>瀏覽學生信息的主頁</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>學號:{{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://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){

相關文章:
主站蜘蛛池模板: 欧美日韩一区在线观看 | 1024亚洲视频 | 亚洲福利视频一区二区三区 | 欧美黄色第一页 | 久久综合狠狠综合久久综合88 | 中国一级毛片视频 | 正在播放国产大学生情侣 | 在线免费观看色 | 成人 在线欧美亚洲 | 国产成年人网站 | 国产尤物二区三区在线观看 | 国产伦一区二区三区四区久久 | 国产日韩欧美综合在线 | 国产在线观看精品一区二区三区91 | 国产在线91| 久久精品视频在线 | 日本一二三本免费视频 | 深夜成人性视频免费看 | 污视频在线观看网址 | 欧美日韩一区二区高清视 | 欧美黄色大片免费 | 欧美一级成人 | 蜜臀网站| 最新的国产成人精品2022 | 寡妇一级a毛片免费播放 | 一级黄色淫片 | 成人午夜视频在线 | 久久国产乱子伦精品免费强 | 天天黄色片 | 亚洲高清成人欧美动作片 | 她也啪97在线视频 | 国产精品久久福利网站 | 青青操视频在线免费观看 | 国产亚洲一区二区精品 | 精品国产一二三区 | 在线国产播放 | 女女同性一区二区三区四区 | 亚洲第一页在线 | 日本精品一区二区三区在线 | 麻豆视频一区二区 | 欧美噜噜噜 |