-
-
Save harimau99/37beb3d6960798bb730cb8a5d94c858c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(angular) { | |
'use strict'; | |
angular.module('learnAngular', []) | |
.controller('postExample', ['$scope', function($scope) { | |
$scope.post = { | |
title: 'Enter Title' | |
}; | |
}]); | |
})(window.angular); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-controller="postExample"> | |
<form ng-submit="submit()"> | |
<input type="text" ng-model="post.title" /> | |
<input type="submit" value="Save" ng-hide="post.title == 'Enter Title'" /> | |
</form> | |
<div>{{post.title}}</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(angular) { | |
'use strict'; | |
angular.module('learnAngular', []) | |
.controller('postExample', ['$scope', function($scope) { | |
$scope.post = { | |
title: 'Enter Title' | |
}; | |
$scope.submit = function(){ | |
alert( 'saving' ); | |
} | |
}]); | |
})(window.angular); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-controller="postsExample"> | |
<h3>Posts:</h3> | |
<div ng-repeat="post in posts"> | |
{{post.title}} | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.controller('postExample', ['$scope', function($scope) { | |
$scope.post = { | |
title: 'Enter Title' | |
}; | |
}] ).controller('postsExample', ['$scope', function($scope) { | |
$scope.posts = [ | |
{ title: 'Post One' }, | |
{ title: 'Post Two' } | |
]; | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(angular) { | |
'use strict'; | |
angular.module('learnAngular', []) | |
.controller('postExample', ['$scope', '$http', function($scope, $http) { | |
$http({ | |
url: 'http://joshpress.net/wp-json/wp/v2/posts/1', | |
cache: true | |
} ).then( function( res ) { | |
$scope.post = res.data; | |
}); | |
}]).controller('postsExample', ['$scope', '$http', function($scope, $http) { | |
$http( { | |
url: 'http://joshpress.net/wp-json/wp/v2/posts/', | |
cache: true | |
} ).then( function ( res ) { | |
$scope.posts = res.data; | |
$scope.totalPages = res.headers('x-wp-totalpages'); | |
$scope.total = res.headers( 'x-wp-total' ); | |
} ); | |
}]); | |
})(window.angular); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(angular) { | |
'use strict'; | |
angular.module('learnAngular', []) | |
.controller('postExample', ['$scope', '$http', function($scope, $http) { | |
$http({ | |
url: 'http://joshpress.net/wp-json/wp/v2/posts/1', | |
cache: true | |
} ).then( function( res ) { | |
$scope.post = res.data; | |
}); | |
$scope.save = function(){ | |
$http({ | |
url: 'http://joshpress.net/wp-json/wp/v2/posts/1', | |
cache: true, | |
method: "POST" | |
} ).then( function( res ) { | |
$scope.post = res.data; | |
}); | |
}; | |
}]).controller('postsExample', ['$scope', '$http', function($scope, $http) { | |
$http( { | |
url: 'http://joshpress.net/wp-json/wp/v2/posts/', | |
cache: true | |
} ).then( function ( res ) { | |
$scope.posts = res.data; | |
$scope.totalPages = res.headers('x-wp-totalpages'); | |
$scope.total = res.headers( 'x-wp-total' ); | |
} ); | |
}]); | |
})(window.angular); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ingotApp.factory( 'groupsFactory', function( $resource ) { | |
return $resource( INGOT_ADMIN.api + 'groups/:id', { | |
id: '@id', | |
_wpnonce: INGOT_ADMIN.nonce, | |
context: 'admin' | |
},{ | |
'query' : { | |
transformResponse: function( data, headers ) { | |
var response = { | |
data: data, | |
headers: headers() | |
}; | |
return response; | |
} | |
}, | |
'update':{ | |
method:'PUT', | |
headers: { | |
'X-WP-Nonce': INGOT_ADMIN.nonce | |
} | |
}, | |
'post':{ | |
method:'POST', | |
headers: { | |
'X-WP-Nonce': INGOT_ADMIN.nonce | |
} | |
}, | |
'save':{ | |
method:'POST', | |
headers: { | |
'X-WP-Nonce': INGOT_ADMIN.nonce | |
} | |
}, | |
'delete':{ | |
method:'DELETE', | |
headers: { | |
'X-WP-Nonce': INGOT_ADMIN.nonce | |
} | |
} | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ingotApp.controller( 'clickDelete', ['$scope', 'groupsFactory', function( $scope, groupsFactory ){ | |
groupsFactory.query( | |
{ | |
page: 1, | |
limit: 10, | |
context: 'admin', | |
type: 'click' | |
}, function ( res ) { | |
if ( res.data.indexOf( 'No matching' ) > -1 ) { | |
$scope.groups = {}; | |
return; | |
}; | |
$scope.groups = JSON.parse( res.data ); | |
var total_groups = parseInt( res.headers[ 'x-ingot-total' ] ); | |
total_pages = total_groups / page_limit; | |
$scope.total_pages = new Array( Math.round( total_pages ) ); | |
$scope.groups.shortcode = []; | |
}); | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$http({ | |
url: 'http://joshpress.net/wp-json/wp/v2/posts/1', | |
} ).then( function( res ) { | |
$scope.post = res.data; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-controller="postExample"> | |
<form> | |
<input type="text" ng-model="post.title" /> | |
</form> | |
<div>{{post.title}}</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment