角度材料datepicker工作而不注入依赖项

时间:2016-11-24 11:01:09

标签: angularjs datepicker angular-material

请在下面找到包含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 个答案:

答案 0 :(得分:1)

实际上有引用,点击,您可以在 Javascript 标签中看到引用,

enter image description here

enter image description here

<强>更新

&#39; ngMaterial&#39;正在加载作为该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模块。

相关问题