Skip to content

Instantly share code, notes, and snippets.

var app = angular.module('myApp', []);
app.controller('MainCtrl', ['$scope', 'myService', function ($scope, myService) {
console.log('online');
$scope.data = myService.outData;
$scope.showData = function () {
myService.showData();
};
}]);
app.service('myService', ['$http', '$rootScope', function ($http, $rootScope) {
// data private access
var inData = {
cpt: 0,
mytext: 'hello who ?',
extData: undefined
};
var loadData = function () {
console.log("loadData");
<div data-ng-controller="MainCtrl">
<h1>text: {{data.text}}</h1>
<input type="text" data-ng-model="data.text" />
<h2>nb update: {{data.cpt}}</h2>
<button type="button" data-ng-click="showData()">Show</button>
<h2>text: {{data.extData}}</h2>
</div>
/*
* http://techasite.blogspot.fr/
* @author asic
*/
print("begin javascript");
print("instanciate Java ArrayList from javascript");
var x = new java.util.ArrayList(4);
package test;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.Invocable;
@asicfr
asicfr / gist:5033199
Created February 25, 2013 20:54
structure
+---webapp <===== la page index et le fichier appcache sont générés à la racine
+---cssext <===== css externes (bootstrap ...)
+---cssin <===== css propre à l'application
+---gen <===== tous les autres fichiers générés sont dans ce répertoire
¦ +---js <===== contrôleur principal de l'application
¦ +---jsmodules <===== fichiers javascript (contrôleur et service) pour chaque entité
¦ +---pages <===== pages html pour chaque entité
¦ +---partials <===== header et footer html
+---img <===== images de l'application (bootstrap)
+---jsext <===== librairies javascript externes (jquery, bootstrap ...)
@asicfr
asicfr / gist:5014121
Created February 22, 2013 15:16
binding
<div id="authorCreate" data-ng-controller="AuthorCreateCtrl">
<h2>Author Create</h2>
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="id">id</label>
<div class="controls">
@asicfr
asicfr / gist:5013977
Created February 22, 2013 14:53
json data store
{
"entities": {
"author": {
"uuid1": {
"firstName": "prenom",
"id": "1",
"lastName": "nom"
},
"uuid2": {}
},
@asicfr
asicfr / gist:5013596
Created February 22, 2013 14:02
bookStoreauthor.controller
bookStoreauthor.controller('AuthorDetailCtrl', ['$scope', '$location', '$routeParams', '$rootScope', 'ApiAuthor', 'ApiStorage', function ($scope, $location, $routeParams, $rootScope, ApiAuthor, ApiStorage) {
$rootScope.logMe("AuthorDetailCtrl");
$scope.idCurrent = $routeParams.id;
$rootScope.logMe("get author ");
$scope.oneauthor = ApiAuthor.get($scope.idCurrent);
...
@asicfr
asicfr / gist:5013444
Created February 22, 2013 13:41
sous controleur et methodes du crud
// author Controllers
bookStoreauthor.controller('AuthorListCtrl', ['$scope', '$location', '$routeParams', '$rootScope', 'ApiAuthor', 'ApiStorage', function ($scope, $location, $routeParams, $rootScope, ApiAuthor, ApiStorage) {
$rootScope.logMe("AuthorListCtrl");
var self = this;
$scope.authors = ApiAuthor.search();
$rootScope.logMe("search end");
// new Author call