How to add a function in AngularJS-factory?

泪湿孤枕 提交于 2020-01-07 03:49:10

问题


I took over an AngularJS (Cordova) project being a newbie in this area. Now I have to add a new "wheel-item" called "Eingepasst", which is different to the existing ones like i.e. "Partnerspiel" (see picture).

When having clicked the button on top-right a valued called "Spielwert" (here: 22) will be written to the 'Model' (talking about MVC).

The related part of the code is inside a "factory"-JavaScript-file" called 'game.factory.js':

angular.module('app').factory('Game', function (Settings, Round)
{

    function MODEL()
    {
        return {
            type:
            [
                {
                    key: 'EI',
                    value: 'Eingepasst',
                    rate: Settings.get('eingepasstRate'), //from there the minus-value is derived for adjusted
                    variants:
                    [
                        { key: 'E0', value: 'Regulär', multiplier: 1, rate: Settings.get('eingepasstRate') }
                    ]
                },

Unfortunately I could not figure out, where 'key', 'value', 'multiplier' and 'rate' derive from...

However I want to add a function call here to run some calculations inside the code snippet above. What do I have to do here? Please be as detailed as possible...

来源:https://stackoverflow.com/questions/37008268/how-to-add-a-function-in-angularjs-factory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!