Skip to content

Instantly share code, notes, and snippets.

'use strict';
beforeEach(function() {
module('lama');
module('lama.system');
module('stateMock');
});
var $httpBackend,$state;
beforeEach(inject(function( _$httpBackend_, _$state_) {
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', '/api/v1/user/menus',[]).respond(200,{});
.controller('UserInnerController', ['$scope', '$filter',
function($scope, $filter) {
$scope.user.created_at = $filter('tsToDate')($scope.user.created_at,'shortDate');
}
])
.directive('lmLoader', function($parse){
var tpl = '<div id="loading"><i class="fa fa-spinner fa-spin fa-4x"></i></div>';
return {
restrict: 'A',
scope : {
condition: '&'
},
link: function(scope, element) {
element.css('position','relative');
scope.$watch('condition()', function(){
// NB solitamente la config viene dal server che scriverà come:
var CONFIG = {/* la mia configurazione*/};
angular.module('myApp.services', [])
.constant('CONFIG',CONFIG)
.value('theme','ungranbeltheme:)')
.factory('UserFactory', function($http, $q) {
var service = {
// our factory definition
user: {},
setName: function(newName) {
in HomeController
$token = csrf_token();
$this->layout->content = View::make('home.content')->with('data', array('token'=> $token, 'user'=> json_encode($userData)));
in blade
@section('content')
<div class="content" data-ui-view></div>
<script type="text/javascript">
window.user = <% $data['user'] %>;
document.cookie = "XSRF-TOKEN=<% $data['token'] %>";
var app = angular.module('plunker', []);
app.controller('BoxController', ['$scope', function ($scope) {
$scope.items = [1, 2, 3, 4, 5];
}]);
app.directive('bxSlider', [function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
;(function(window, angular, _, undefined) {
'use strict';
var underscore = angular.module('underscore', []);
underscore.factory('_', function() {
return window._; //Underscore must already be loaded on the page
});
})(window, angular, _);
angular.module('myApp', ['underscore'])
function takePhoto() {
navigator.camera.getPicture(cameraSuccess, cameraError, {
quality : 50,
destinationType: Camera.DestinationType.DATA_URL
});
}
function cameraSuccess(imageData) {
var inmomentNameSpace = angular.module('inmoment', []);
inmomentNameSpace.controller('sampleController', function sampleController($scope,$timeout){
$scope.cats = [];
db.transaction (
function(tx) {
$("#catList").empty();
/* what's the hack is going on here !
* In the angularjs world is strictly forbidden
* using reference to dom in the controller :)
* Go with a directive instead.
app.controller('ItemsUpdateController', function ($scope, item, Items, $state) {
$scope.item = item;
$scope.item.$loaded().then(function(data) {
$scope.item = data;
});
$scope.add = function() {
var item = {};
item.$id = $scope.item.$id;
item.title = $scope.item.title;
item.ingredients = $scope.item.ingredients;