@@ -8,6 +8,22 @@ |
||
| 8 | 8 |
* Controller of the domainManagerApp |
| 9 | 9 |
*/ |
| 10 | 10 |
angular.module('domainManagerApp.addPost', ['firebase', 'domainManagerApp.userData'])
|
| 11 |
- .controller('AddPostController', ['$scope', 'UserData', function ($scope, UserData) {
|
|
| 12 |
- |
|
| 11 |
+ .controller('AddPostController', ['$scope', 'UserData', '$firebase', function ($scope, UserData, $firebase) {
|
|
| 12 |
+ $scope.AddDomain = function() {
|
|
| 13 |
+ var firebaseObj = new Firebase("https://j1x-cpanel.firebaseio.com/");
|
|
| 14 |
+ |
|
| 15 |
+ var domainsRef = firebaseObj.child("domains");
|
|
| 16 |
+ |
|
| 17 |
+ domainsRef.push({
|
|
| 18 |
+ name: $scope.domain.name, |
|
| 19 |
+ userId: UserData.getUser() |
|
| 20 |
+ }, function(error) {
|
|
| 21 |
+ if (error) {
|
|
| 22 |
+ console.log('Error - Domain not created');
|
|
| 23 |
+ } else {
|
|
| 24 |
+ console.log('Domain created');
|
|
| 25 |
+ } |
|
| 26 |
+ }); |
|
| 27 |
+ |
|
| 28 |
+ } |
|
| 13 | 29 |
}]); |
@@ -1,33 +1,25 @@ |
||
| 1 | 1 |
<div class="container"> |
| 2 | 2 |
|
| 3 |
- <form class="form-horizontal"> |
|
| 3 |
+ <form class="form-horizontal" ng-submit="AddDomain()"> |
|
| 4 | 4 |
<fieldset> |
| 5 | 5 |
|
| 6 | 6 |
<!-- Form Name --> |
| 7 |
- <legend>Create Post</legend> |
|
| 7 |
+ <legend>Add Domain</legend> |
|
| 8 | 8 |
|
| 9 | 9 |
<!-- Text input--> |
| 10 | 10 |
<div class="form-group"> |
| 11 | 11 |
<label class="col-md-4 control-label" for="txtTitle">Title</label> |
| 12 | 12 |
<div class="col-md-4"> |
| 13 |
- <input id="txtTitle" name="txtTitle" type="text" placeholder="placeholder" class="form-control input-md"> |
|
| 13 |
+ <input id="domainTitle" ng-model="domain.name" name="txtTitle" type="text" placeholder="domain name" class="form-control input-md"> |
|
| 14 | 14 |
|
| 15 | 15 |
</div> |
| 16 | 16 |
</div> |
| 17 | 17 |
|
| 18 |
- <!-- Textarea --> |
|
| 19 |
- <div class="form-group"> |
|
| 20 |
- <label class="col-md-4 control-label"for="txtPost">Post</label> |
|
| 21 |
- <div class="col-md-4"> |
|
| 22 |
- <text areaclass="form-control" id="txtPost" name="txtPost"></textarea> |
|
| 23 |
- </div> |
|
| 24 |
- </div> |
|
| 25 |
- |
|
| 26 | 18 |
<!-- Button --> |
| 27 | 19 |
<div class="form-group"> |
| 28 | 20 |
<label class="col-md-4 control-label"for="singlebutton"></label> |
| 29 | 21 |
<div class="col-md-4"> |
| 30 |
- <input id="singlebutton"name="singlebutton"class="btn btn-primary"type="submit"value="Publish"/> |
|
| 22 |
+ <input id="singlebutton" ng-disabled="!domain.name" name="singlebutton"class="btn btn-primary"type="submit"value="Add"/> |
|
| 31 | 23 |
</div> |
| 32 | 24 |
</div> |
| 33 | 25 |
|