简体   繁体   English

Angular.js-不进入控制器内部

[英]Angular.js - not enter inside a controller

Why not enter in AddTaskComponentController and display my console.log('TESTE456214651') ? 为什么不输入AddTaskComponentController并显示我的console.log('TESTE456214651') The code is in the same archive, because I'm using grunt. 该代码在同一存档中,因为我使用的是grunt。

(function() {
    'use strict';

    angular.module('dailyTasksApp', []).config(config)

    function config($routeProvider, $locationProvider) {
        $locationProvider.html5Mode({
            enabled: true,
            requireBase: false
        });

        $routeProvider.when('/', {
            templateUrl: 'modules/construction-employees-daily-tasks/app/app.component.html'
        }).when('/adicionar-tarefa', {
            templateUrl: 'modules/construction-employees-daily-tasks/add-task-component/add-task.component.html'
        })
    }
})();

(function(){
    'use strict';

    angular.module('dailyTasksApp').component('addTaskComponent', {
        templateUrl: '/modules/construction-employees-daily-tasks/add-task-component/add-task.component.html',
        controller: AddTaskComponentController
    })

    function AddTaskComponentController() {
        console.log("TESTE456214651");
    }
})();

You should declare your function as an Angular controller. 您应该将函数声明为Angular控制器。

(function(){
    'use strict';

    angular
        .module('dailyTasksApp', [])
        .config(config)

    function config($routeProvider, $locationProvider) {
        $locationProvider.html5Mode({
            enabled: true,
            requireBase: false
        });

        $routeProvider
            .when('/', {
                templateUrl: 'modules/construction-employees-daily-tasks/app/app.component.html'
            })
            .when('/adicionar-tarefa', {
                templateUrl: 'modules/construction-employees-daily-tasks/add-task-component/add-task.component.html'
            })
    }
})();

(function(){
    'use strict';

    angular
        .module('dailyTasksApp')
        .controller('AddTaskComponentController',
           function(){
               console.log("TESTE456214651");
           })
        .component('addTaskComponent', {
            templateUrl: '/modules/construction-employees-daily-tasks/add-task-component/add-task.component.html',
            controller: AddTaskComponentController
        })

})();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM