在阵列中推送数据-角度/离子
Pushing Data in Array - Angular/Ionic
我正在开发一个应用程序,我想在数组中推送数据,但它不起作用。也许你可以看看我的代码。
抛出的错误消息:ionic.bundle.js:25642类型错误:无法读取未定义的属性"title"范围内$scope.createEx(app.js:63)范围内$scope.createEx(app.js:62)
Index.html
<script id="templates/addEx.html" type="text/ng-template">
<ion-view view-title="GymHelper">
<ion-content padding="true" ng-controller="OverallCtrl">
<div class="list">
<label class="item item-input item-floating-label">
<span class="input-label">Exercise Title</span>
<input ng-model="exer.title" type="text" placeholder="Title">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Exercise Sets</span>
<input ng-model="exer.set" type="text" placeholder="Sets">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Exercise Reps</span>
<input ng-model="exer.rep" type="text" placeholder="Reps">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Extra Information</span>
<input ng-model"exer.inf" type="text" placeholder="Extra Information">
</label>
<label class="item item-input item-select">
<div class="input-label">
Muscle
</div>
<select ng-model="selOption">
<option>Chest</option>
<option>Biceps</option>
<option>Back</option>
<option>Stomach</option>
<option>Legs</option>
<option>Triceps</option>
<option>Shoulders</option>
<option>Traps</option>
</select>
</label>
</div>
<button class="button button-block button-positive" ng-click="createEx(exer)">
Create Exercise
</button>
</ion-content>
</ion-view>
</script>
App.js
app.controller('OverallCtrl', function($scope, $ionicListDelegate, $state) {
$scope.selOption == "Chest";
$scope.createEx = function(exer) {
if($scope.selOption == "Chest"){
$scope.chestEx.push({title: exer.title, sets: exer.set, reps: exer.rep, exInf: exer.inf});
console.log("Pushed to Chest Array.");
$state.go('chest')
};
}
$scope.chestEx = [
{title: "Crowls", sets: 3, reps: 15, exInf: "Make 5 minute pause between Sets."},
]
})
请定位
$scope.chestEx = [
{title: "Crowls", sets: 3, reps: 15, exInf: "Make 5 minute pause between Sets."},
]
在$scope.createEx函数
相关文章:
- 如何在离子框架+有角度的框架中制作顶部标签
- 我必须点击两次才能激活任何按钮操作(离子/角度)
- 离子和角度:带标签的应用程序上的路线
- 离子和角度:json不会;t显示
- 离子/角度$urlRouterProvider.otherwise问题
- 在阵列中推送数据-角度/离子
- 离子/角度日期输入使用时刻以编程方式设置
- 离子/角度替代$stateChangeStart
- 以离子和角度动态提醒$scope.data
- 离子/角度指令绑定到滚动
- 制作一个$window.location.reload(true);在离子/角度中仅执行一次
- 以角度 + 离子形式显示的条件:显示 Id 是否具有特定值
- 离子/角度:使用“大纲”详细信息模式时,不会显示详细信息页面
- 角度/离子点击事件传播
- 单元测试角度/离子项目
- 角度/离子谷歌地图的状态变化
- 角度离子徽章计数未更新
- 重新加载重复角度/离子
- 角度/离子 - 型号不会更新控制器中的$scope
- 刷新后退按钮上的页面,角度/离子