我创建了一个HTML页面,该页面允许我使用JS从列表中添加和删除行程。我定义了一个包含5个不同行程的数组。
我想做的是创建一个函数,该函数初始化我已存储的当前数据,并且当页面启动时,仅包含我在控制器中定义的5条路线。它还应该清理一下我的代码。
这是我在controller.js文件中的代码;
angular.module("itsItinerary").controller("itineraryController", function ($scope, $http){ // Array of Itinerarys
$scope.isEditing = false; //
$scope.itineraries = [
{
id: 1,
itiName: "October Business Development trip 2020",
destination: "Germany",
purpose: "Work",
startDate: new Date("2020-10-03"),
endDate: new Date("2020-10-10")
},
{
id: 2,
itiName: "November Client-site visit 2020",
destination: "America",
purpose: "Work",
startDate: new Date("2020-11-05"),
endDate: new Date("2020-11-08")
},
{
id: 3,
itiName: "January Scoping visit 2021",
destination: "China",
purpose: "Work",
startDate: new Date("2021-01-15"),
endDate: new Date("2021-01-23")
},
{
id: 4,
itiName: "May Recruitment visit 2021",
destination: "India",
purpose: "Work",
startDate: new Date("2021-05-21"),
endDate: new Date("2021-05-30")
},
{
id: 5,
itiName: "July Conversion visit 2021",
destination: "Germany",
purpose: "Work",
startDate: new Date("2021-07-08"),
endDate: new Date("2021-07-15")
}
];
感谢您抽出宝贵时间来回答