Angular 材質日期選擇器在不注入依賴項的情況下工作 (Angular material datepicker working without injecting dependencies)


問題描述

Angular 材質日期選擇器在不注入依賴項的情況下工作 (Angular material datepicker working without injecting dependencies)

請在下面找到包含 datepicker 代碼的 codepen,其中添加了少量腳本(moment.js,material.js),但依賴項未註入應用程序。

http://codepen.io/anon/pen/vNLyGJ

我檢查了代碼導出,在其中我可以看到模塊不是創建而是調用。

如果不注入 index.js 中的依賴項,這是如何工作的。

angular.module('MyApp')
.controller('AppCtrl', function($scope) {
  $scope.myDate = new Date();

.config(function($mdDateLocaleProvider) {
 $mdDateLocaleProvider.formatDate = function(date) {
return moment(date).format('YYYY‑MM‑DD');
  };
 });

參考解法

方法 1:

Actually the references are there, Click and you could see the references in the Javascript tab,

enter image description here

enter image description here

UPDATE:

'ngMaterial' is being loaded as a dependency on another file at the end on that codepen:

https://s3‑us‑west‑2.amazonaws.com/s.cdpn.io/t‑114/assets‑cache.js

var demoExampleAppName = 'MyApp';
  angular.module(demoExampleAppName, ['ngMaterial', 'ngMessages'])
    .run(function($templateCache) {
      angular.forEach(assetMap, function(value, key) {
        $templateCache.put(key, value);
      });
});

MyApp Module is already defined in this case.

(by RaphaelSajeetharan)

參考文件

  1. Angular material datepicker working without injecting dependencies (CC BY‑SA 2.5/3.0/4.0)

#angular-material #angularjs #datepicker






相關問題

除了現有的 md 芯片外,如何添加自定義 md 芯片? (how to add custom md-chips in addition to existing md-chips?)

角材料中心佈局 (Angular Material center layout)

如何使 md-action 按鈕粘在 md-card 的底部? (How to make md-action buttons to stick to the bottom of md-card?)

Angular 材質日期選擇器在不注入依賴項的情況下工作 (Angular material datepicker working without injecting dependencies)

如何禁用墊下拉選項從一到二? (How to disable mat drop down option from one to two?)

角度材質工具欄不繼承自角度材質 (Angular material toolbar not inheriting from angular materials)

如何更改 Angular Material 中的標籤標籤? (How to change tab label in Angular Material?)

如何使用按鍵角 9 選擇下拉值 (how to select the dropdown value using key press angular 9)

在 mat-grid-tile Angular 上顯示 flex (display flex on mat-grid-tile Angular)

不能使用 Angular Material 日期範圍日期過濾器 (Can't use Angular Material date range date filter)

如何更改 matInput 佔位符的顏色? (How can I change the color of placeholder of matInput?)

使用 mat-expansion-panel 時增加下拉菜單的高度 (Increase the height of Dropdown menu when using mat-expansion-panel)







留言討論