Wednesday, October 11, 2017

$routeProvider doesn’t pass the controller to my template

I have tried to load a template dinamically in angular using ngRoute…
The problem is that i Use this code :

(app.js route configuration)

app.config(function($routeProvider) {
    $routeProvider.when("/password", {
        templateUrl : "../password/index.html",
        controller: 'LoginController',
        controllerAs : 'loginCtrl',
        reloadOnSearch : false
    });
});

This is the HTML template (../password/index.html)

<div class=" et_pb_row et_pb_row_0">
   ....
 <form ng-submit="loginCtrl.controllaPassword()">
   ....
</div>

(app.js controller )

this.controllaPassword = function(){
    alert("kuajia");
};

At the moment the code appear on the main html page(login.html) where i declare ng-app, but it doesn’t shpw the alert.

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/11/routeprovider-doesnt-pass-the-controller-to-my-template/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment