javascript - angular4模式实验室

标签 javascript angular patternlab.io

由于 Angular 2 或 Angular 4 需要为每个组件编写过多的 HTML/TS/CSS 代码。如果我将 Pattern lab 与 Angular 4 结合使用会怎样?

我认为使用 Pattern Lab 需要更多维护,我们需要在其中编写更多代码来维护分子/原子和 Pattern lab 中的 JSON 文件。

您能否建议使用 Angular 为 2/4 的 Pattern Lab 是否好?

任何帮助将不胜感激!

最佳答案

1) Yarn install

2) Yarn add angular

3) resources->assets->js->admin->app.module.js

4) app.module.js

      (function () {
                    'use strict';

                    var app = angular.module('App', [
                            'app.S1'
                    ], function ($httpProvider) {
        $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-          urlencoded';
             $httpProvider.defaults.headers.post['X-Requested-With'] = 'XMLHttpRequest';
        $httpProvider.defaults.headers.put['Content-Type'] = 'application/x-www-form-       urlencoded';
            $httpProvider.defaults.headers.put['X-Requested-With'] = 'XMLHttpRequest';
        }).config(['$qProvider', function ($qProvider) {
            $qProvider.errorOnUnhandledRejections(false);
        }]);
    })();


5) Add dependency in webpackmix



mix.scripts([
         'node_modules/angular/angular.min.js'
],'public/js/main.plugin.js');

mix.babel([
             /*Main module for all*/
    'resources/assets/js/admin/app.module.js',

                /*Controller and services*/
            'resources/assets/js/admin/S1/S1.module.js',
            'resources/assets/js/admin/S1/S1.js',
],'public/js/admin.plugin.js');


6)  make folder in admin with name S1.

7) resources->assets->js->admin->S1->S1.module.js

8) S1.module.js


    (function(){
                'use strict';
                angular.module('app.S1', []);
    })();

9) resources->assets->js->admin->S1->S1.js

10)  S1.js

(function(){
    'use strict';

    angular.module('app.S1')
            .controller('s1Controller', s1Controller);

    /* @ngInject */
    function s1Controller($scope){
        /*jshint validthis: true */
         var vm = this;

         activate();

         function activate(){
             console.log("here call");
         }
    }

})();

关于javascript - angular4模式实验室,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46640398/

相关文章:

angular - 如何在 Angular 2 中重新加载相同 URL 的组件?

javascript - 使用带有 tap 和 map RxJS 运算符的函数时出现 TypeScript 类型错误?

javascript - karma : Move Folder -> Missing Error Handler on Socket?

javascript - 将 selectize.js 添加到patternlab.io 实现中

node.js - 带有第二个 package.json 的模式实验室

javascript - 在 Facebook Graph API 查询中使用 with=location 时出现 "Uncaught (in promise) undefined"错误

javascript - 自定义 Twitter 时间轴小部件

javascript - 试图从自动完成 google.api 上选择的地方获取引用

javascript - 如何使用表中的 td 值设置列(<td>)宽度