I'm new to both AngularJs and ngDialog, and I'm having trouble getting my bindings to work between the ngDialog modal and my controller. I injected the controller's scope into the modal by specifying { scope: $scope }, and I have access to methods defined in the controller, but the bindings to models defined in the controller aren't functioning properly.
I'm trying to use a modal to allow the user to add an address to an organization.
Here's main.js
angular.module('wizardApp')
.controller('MainCtrl', ['$scope', 'ngDialog', MainCtrl]);
function MainCtrl($scope, ngDialog) {
$scope.hide_wizard_button = false;
$scope.open_wizard = function () {
$scope.hide_wizard_button = true;
ngDialog.open({
template: 'wizard',
controller: 'wizardCtrl',
scope: $scope
})
}
}
angular.module('wizardApp')
.controller('wizardCtrl', ['$scope', wizardCtrl]);
function wizardCtrl($scope){
$scope.step = 1;
$scope.name = null;
$scope.phone_number = null;
$scope.email_address = null;
$scope.password = null;
$scope.step_forward = function(){
if ($scope.step === 1){
if(validate_name($scope.name) && validate_phone_number($scope.phone_number) && validate_address($scope.address)){
$scope.step++;
}
}
if ($scope.step == 2){
if(validate_email($scope.email_address) && validate_password($scope.password)){
$scope.step++;
}
}
};
Following is my ng-template:
<script type="text/ng-template" id="wizard">
<form id="msform">
<!-- progressbar -->
<ul id="progressbar">
<li ng-class="{true: 'active'}[step==1]">Personal Details</li>
<li ng-class="{true: 'active'}[step==2]">Social Profiles</li>
<li ng-class="{true: 'active'}[step==3]">Personal Details</li>
</ul>
<!-- fieldsets -->
<fieldset ng-if="step == 1">
<h2 class="fs-title">Enter Your personal Details</h2>
<h3 class="fs-subtitle">This is step 1</h3>
<input type="text" placeholder="Name" ng-model="name"/>
<input type="text" placeholder="Phone Number" ng-model="phone_number"/>
<input type="text" placeholder="Address" ng-model="address"/>
<input type="button" class="next action-button" value="Next" ng-click="step_forward()"/>
</fieldset>
<fieldset ng-if="step == 2">
<h2 class="fs-title">Email Verification</h2>
<h3 class="fs-subtitle">Your Email Address and password</h3>
<input type="text" name="email" placeholder="Email Address"/>
<input type="password" name="password" placeholder="Password"/>
<input type="button" name="previous" class="previous action-button" value="Previous" ng-click="step_back()"/>
<input type="button" name="next" class="next action-button" value="Next" ng-click="step_forward()"/>
</fieldset>
<fieldset ng-if="step == 3">
<h2 class="fs-title">Thank You for signing up!</h2>
</fieldset>
</form>
</script>
The error is cannot read property of null, Which means the $scope.name is not getting updated.