Session Data with Durandal

前端 未结 2 1335
悲&欢浪女
悲&欢浪女 2020-12-20 09:11

I am just getting started with Durandal.js so excuse me for the silly quesstion...

When a user makes it\'s first request to the app it is asked to choose a \'profile

2条回答
  •  生来不讨喜
    2020-12-20 10:08

    As an alternative to Evan's answer, which is definitively the correct AMD approach... have you considered using a global object for that purpose?

    in main.js

    window.myApp = {
        prop1: 'value',
        subOne: {
             prop1: 'value'
        } 
       ... 
    }
    

    That will allow you to access the global myApp object everywhere. I know that some people will consider that as global namespace pollution and in general a bad practice, but in a SPA project (where you control window) I'd consider this still a viable approach.

提交回复
热议问题