Exploring the realm of web development, I recently embarked on my journey with the MEAN stack. Facing a seemingly straightforward question that has left me stumped, I turned to various resources for answers without much luck. So, here I am, reaching out in hopes of cracking this puzzle.
In essence, what I aim to achieve is:
- Extract multiple values from an array
- Integrate these fetched values into a new scope
- Handle all operations within the controller to facilitate posting of all values, including the freshly added one, to my database (mongo).
The desired scenario involves extracting and combining the values as follows:
index = value[0]*weight[0] + value[1]*weight[1].... and so forth
Within my Angular controller lies the following code snippet:
$scope.alerts = [
{ title: 'someTitle1',
weighttitle: 'someweightTitle1',
value: 1,
weight: 30,
options: {
showTicks: true,
hidePointerLabels: true,
hideLimitLabels: true,
stepsArray: [
{ value: 1, legend: 'Very poor' },
{ value: 2, legend: 'Very poor' },
{ value: 3, legend: 'Fair' },
{ value: 4, legend: 'Very poor' },
{ value: 5, legend: 'Average' }
]
}
},
{ title: 'someTitle2',
weighttitle: 'someweightTitle2',
value: 1,
weight: 60,
options: {
showTicks: true,
hidePointerLabels: true,
hideLimitLabels: true,
stepsArray: [
{ value: 1, legend: 'Very poor' },
{ value: 2, legend: 'Very poor' },
{ value: 3, legend: 'Fair' },
{ value: 4, legend: 'Very poor' },
{ value: 5, legend: 'Average' }
]
}
}
];
I attempted a solution along the lines of:
$scope.index = alert.value*alert.weight
However, my attempts fell short. At this juncture, I find myself at a loss on how to retrieve these values effectively. Perhaps my grasp of the underlying concept is slightly off the mark.
I would greatly appreciate any guidance offered!
While previous solutions did yield results, they lacked dynamic adjustments. The HTML structure pertaining to this issue is depicted below:
<section ng-controller="ArticlesController">
<div class="page-header">
<h1>Neue Evaluierung</h1>
</div>
<div class="col-md-12">
<form name="articleForm" class="form-horizontal" ng-submit="create(articleForm.$valid)" novalidate>
<fieldset>
<div class="row form-group">
<h3>Projekttitel</h3><input type="submit" class="btn btn-default btn-lg btn-success">
</div>
<div ng-show="error" class="text-danger">
<strong ng-bind="error"></strong>
</div>
<input name="title" type="text" ng-model="title" id="title" class="form-control">
<div ng-repeat="alert in alerts">
<h3>{{alert.someTitle}}</h3>
<input type="number" ng-model="alert.value"/>
<div>
<rzslider rz-slider-model="alert.value"
rz-slider-options="alert.options"></rzslider>
</div>
<br>
<br>
<br>
<br>
<div>
<h4>{{alert.someweightTitle}}</h4>
<input type="number" ng-model="alert.weight"/>
<div>
<md-slider flex md-discrete ng-model="alert.weight" step="1" min="1" max="100" aria-label="rating"></md-slider>
</div>
</div>
<input type="number" ng-model="index"/>
<input type="number" ng-model="indexdynamic"/>
</div>
</fieldset>
</form>
</div>
</section>