私はRequireとAngularの両方が初めてです。私の質問は、コントローラーがモジュールでホストされている場合、ng-click でコントローラーにアクセスする方法です。私の場合、次のファイルが必要です。
-- これはコントローラ ファクトリです --
'use strict';
define(['angular', 'controllers/authenticationController'], function (angular, authenticationController) {
var controllers = angular.module('myapp.controllers', ['myapp.services']);
controllers.controller('authenticationController', authenticationController);
return controllers;
});
-- これがコントローラーです --
'use strict';
define(function () {
var controller = function ($scope, authenticationService) {
$scope.signin = function() {
authenticationService.signin();
}
};
controller.$inject = ['$scope', 'authenticationService'];
return controller;
});
ここにhtml部分があります。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Project Setup</title>
<meta charset="utf-8"/>
<link href="scripts/lib/Bootstrap/css/bootstrap.css" rel="stylesheet" />
<link href="scripts/lib/bootstrap/css/bootstrap-responsive.css" rel="stylesheet" />
</head>
<body>
<div ng-controller="authorizationController">
<button ng-click="signin">Do the signin here</button>
</div>
<div ng-view></div>
<script type="text/javascript" data-main="scripts/main" src="scripts/lib/require/require.js"></script>
</body>
</html>
どんな助けでも大歓迎です。