I am new to Web Development and started out with a MEAN-Stack (Mongo, Express, Angular, Node).
In short, I would like to get a value from mongo into my angular controller to use multiple values from mongo in a formula like this:
value11*value12 + value21*value22 ...etc
My Problem in more detail:
- I already wrote with a fieldset some data into mongo:
HTML Snippet
<fieldset>
<rzslider rz-slider-model="value11"
rz-slider-options="slider11.options"></rzslider>
<md-slider flex md-discrete ng-model="value12" step="1" min="1 max="100 aria-label="rating"></md-slider
</fieldset>
Controller.js Snippet. The rzslider comes from there https://github.com/angular-slider/angularjs-slider
The md-slider from Angular-Material
$scope.slider11 = {
options: {
showTicks: true,
hidePointerLabels: true,
hideLimitLabels: true,
stepsArray: [
{ value: 1, legend: 'Very poor' }
{ value: 2, legend: 'Poor' },
{ value: 3, legend: 'Fair' },
{ value: 4, legend: 'Good' },
{ value: 5, legend: 'Very Good' }
]
}
};
$scope.value12 = 40;
//Create new Article object
var article = new Articles
value11: this.value11,
value12: this.value12,
At this point everything is working and in mongo the set values get stored.
- In this second step I would like to get the value from the database into a different controller to include them in above mentioned formula. The only thing working so far is to recall the values like this in the html view directly:
HTML Snippet
{{article.value11 * article.value12}}
which works, as far as I understood thanks to a query like below.
Controller snippet
// Find a list of Articles
$scope.find = function () {
$scope.articles = Articles.query();
};
But ultimately I would like to recall the database values and define them as a new $scope in a controller.