Kết Để chạy ví dụ này, bạn cần tạo testAngularJS.jsp and data.txt tới webserver Mở tệptestAngularJS.jsp http://vietjack.com/ Trang chia sẻ học on","url":"https://123docz.net/document/4647733-ajax-trong-angularjs-26-bai-huong-dan-angularjs-mien-phi-pdf.htm","image":"https://media.store123doc.com/images/document/2017_12/03/larger_bek1512216200.jpg"}
  1. Trang chủ
  2. » Thể loại khác

Ajax trong AngularJS | 26 bài hướng dẫn AngularJs miễn phí PDF

4 175 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

http://vietjack.com/angularjs/index.jsp Copyright © vietjack.com Ajax AngularJS AngularJS cung cấp điều khiển $http mà làm service để đọc liệu từ server Server tạo database call để nhận ghi AngularJS cần liệu định dạng JSON Khi liệu sẵn sàng, $http sử dụng để nhận liệu từ server theo cách sau đây: function studentController($scope,$http) { var url="data.txt"; $http.get(url).success( function(response) { $scope.students = response; }); } Ở tệp data.txt chứa ghi student $http service tạo ajax call lấy kết trả cho đối tượng student “students” model dùng để vẽ bảng với HTML Các ví dụ data.txt [ { "Name" : "Mahesh Parashar", "RollNo" : 101, "Percentage" : "80%" }, { "Name" : "Dinkar Kad", "RollNo" : 201, "Percentage" : "70%" }, { "Name" : "Robert", "RollNo" : 191, "Percentage" : "75%" }, http://vietjack.com/ Trang chia sẻ học online miễn phí Page http://vietjack.com/angularjs/index.jsp Copyright © vietjack.com { "Name" : "Julian Joe", "RollNo" : 111, "Percentage" : "77%" } ] testAngularJS.jsp Angular JS Includes table, th , td { border: 1px solid grey; border-collapse: collapse; padding: 5px; } table tr:nth-child(odd) { background-color: #f2f2f2; } table tr:nth-child(even) { background-color: #ffffff; } AngularJS Sample Application Name Roll No Percentage http://vietjack.com/ Trang chia sẻ học online miễn phí Page http://vietjack.com/angularjs/index.jsp Copyright © vietjack.com {{ student.Name }} {{ student.RollNo }} {{ student.Percentage }} function studentController($scope,$http) { var url="data.txt"; $http.get(url).success( function(response) { $scope.students = response; }); } Kết Để chạy ví dụ này, bạn cần tạo testAngularJS.jsp and data.txt tới webserver Mở tệptestAngularJS.jsp với địa URL server trình duyệt web xem kết http://vietjack.com/ Trang chia sẻ học online miễn phí Page http://vietjack.com/angularjs/index.jsp http://vietjack.com/ Trang chia sẻ học online miễn phí Copyright © vietjack.com Page ... src="http:/ /ajax. googleapis.com /ajax/ libs /angularjs/ 1.2.15/angular.min.js"> Kết Để chạy ví dụ này, bạn cần tạo testAngularJS.jsp and data.txt tới webserver Mở tệptestAngularJS.jsp... http://vietjack.com/ Trang chia sẻ học online miễn phí Page http://vietjack.com /angularjs/ index.jsp http://vietjack.com/ Trang chia sẻ học online miễn phí Copyright © vietjack.com Page ... Roll No Percentage http://vietjack.com/ Trang chia sẻ học online miễn phí Page http://vietjack.com /angularjs/ index.jsp Copyright © vietjack.com

Ngày đăng: 02/12/2017, 19:03

Xem thêm:

TỪ KHÓA LIÊN QUAN