Как программно перечислить все свойства, определенные при выполнении MSBuild?

Хорошо, насколько я понимаю, вам нужны данные json, прежде чем что-либо еще из пользовательского интерфейса загружается (так как это данные, которые требуются, прежде чем сайт сам загрузится).

Таким образом, вы не можете сделать http в фазе конфигурации, и если вы звоните в фазе run, вы должны подождать, пока не будет сделан основной вызов http (Позвоним ему /site_data/). [1119 ]

  1. Не используйте ng-app в index.html

  2. В файле app.js

    (function() {
    
    var initInjector = angular.injector(['ng']);
    var $http = initInjector.get('$http');
    $http.get('/site_data/',{headers: {'Cache-Control' : 'no-cache'}}).then(
        function (response) {
            angular.module('walletApp.info', []).constant('SITE_CONF_DATA', response.data);
    
            angular.element(document).ready(function() {
                angular.bootstrap(document, ['walletApp']); //<--  manual bootstrapping of `ng-app`
            });
        }
      );
    })();
    
    var app = angular.module('walletApp',['walletApp.info']);
    app.config(function(SITE_CONF_DATA){
       // Bingo, you have the data
    })
    
    app.run().....
    
    app.controller...
    
    app.factory.....
    

[ 1122] У этого подхода есть недостаток, заключающийся в том, что ваш сайт будет загружен после разрешения вызова http.

Обновление

Что касается комментариев, вы пытаетесь создать гибридное приложение, поэтому посмотрите на эту демонстрацию .

  ngOnInit() {
    // Ensure AngularJS is only bootstrapped once.
    if (!angularJsBootstrapped) {
      this.http.get('https://jsonplaceholder.typicode.com/todos/1').delay(5000).subscribe(res => {
        angular.module('data',[]).constant('DATA',res);
        this.upgrade.bootstrap(document.body, [module.name]);
        setUpLocationSync(this.upgrade);
        angularJsBootstrapped = true;
      })
    }
  }

Я создал constant, создав модуль после разрешения http, а затем вручную загрузил модуль angularJS.

angular.module('data',[]).constant('DATA',res);

Нечто подобное может быть полезно для описываемой вами ситуации.

12
задан Cœur 2 November 2018 в 12:19
поделиться

1 ответ

If you run the build with /verbosity:detailed or /verbosity:diagnostic you will get very detailed output of all the properties that was used during your build process. However I suspect you want to change a config type file after/before you copy the builded files to another location? In that case there is several mechanismes to do that, what we have found to work pretty good, is the MSBuildCommunity tasks that can be found here on code plex

If you would like to see some samples of this I would be glad to post them

5
ответ дан 2 December 2019 в 23:31
поделиться
Другие вопросы по тегам:

Похожие вопросы: