I thought I would ask here, incase there is dreamfactory solution.
im trying to call a parent controller function from inside .directive(‘dreamfactoryUserLogin’
.controller('LoginCtrl', ['$scope', '$location', '$state', 'UserEventsService', function($scope, $location, $state, UserEventsService) {
// $scope.$on(UserEventsService.login.loginSuccess, function(e, userDataObj) {
// $scope.$parent.currentUser = userDataObj;
// $location.url('/');
// });
$scope.registerUser = function(){
console.log('load')
//$state.go('app.register');
}
}])
// Directive for Login. This is does our login work and provides the attachment point for
// the login portion of our module.
.directive('dreamfactoryUserLogin', ['MODUSRMNGR_ASSET_PATH', 'DSP_URL', '$http', '$cookies', '$cookieStore', 'UserEventsService', 'UserDataService', 'dfObjectService',
function (MODUSRMNGR_ASSET_PATH, DSP_URL, $http, $cookies, $cookieStore, UserEventsService, UserDataService, dfObjectService) {
return {
controller: 'LoginCtrl',
// only allow as HTML tag
restrict: 'E',
// don't show directive tag
replace: true,
// isolate scope
// scope: {
// options: '=?'
// },
// template path
templateUrl: MODUSRMNGR_ASSET_PATH + 'views/login.html',
// link it up
link: function (scope, elem, attrs) {
// CREATE SHORT NAMES
scope.es = UserEventsService.login;
// PUBLIC VARS
// This holds our options object. If we don't provide an options object
// it defaults to showing the template. This is currently the only option
var defaults = {showTemplate: true};
scope.options = dfObjectService.mergeObjects(scope.options, defaults);
// This is included on the top level tag of our directive template and
// controls whether the template is rendered or not.
scope.showTemplate = scope.options.showTemplate;
scope.loginActive = true;
// PUBLIC API
// The public api section contains any functions that we wish to call
// in our HTML templates. Functions placed here should be the only
// functions that are 'accessible' or called through our HTML template.
// The only logic that should ever be included is logic pertaining to whether
// or not we should run the complex implementation. Things like using a confirm
// function to decide whether a record should be deleted or not go here.
// This is the function we call in the UI for login.
scope.login = function (credsDataObj) {
// This calls our complex implementation of login()
scope._login(credsDataObj);
};
scope.showForgotPassword = function () {
scope._toggleForms();
};
scope.showLoginForm = function () {
scope._toggleForms();
};
scope.registerUser = function(){
LoginCtrl.registerUser();
}
HTML
<label class="item">
<input class="button button-light" id="submit-login" type="submit" value="Login">
<button class="button button-light" id="forgot-password-active" type="button"
data-ng-click="showForgotPassword()">Forgot Password</button>
<button class="button button-light" id="forgot-password-active" type="button"
data-ng-click="registerUser()">Register</button>
</label>