Skip to content

Instantly share code, notes, and snippets.

@jacoor
Created July 11, 2014 03:06
Show Gist options
  • Save jacoor/8a67ef98205d1df16473 to your computer and use it in GitHub Desktop.
Save jacoor/8a67ef98205d1df16473 to your computer and use it in GitHub Desktop.
/* jslint browser: true, undef: true, newcap: true, forin: true, sub: true, white: true, indent: 4, unused: false */
/* globals define: true */
define(
[
'angularAMD',
'angular-mm-foundation',
'selectize-ng'
], function (angularAMD) {
$.noConflict();
var App = angular.module('App', ['mm.foundation', 'selectize-ng']).config(function($interpolateProvider){
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
}
);
return App;
}
);
{% extends 'base.html' %}
{% load i18n %}
{% block body_content %}
<p>Below is moms autocomplete controller</p>
<div data-ng-controller="MomsAutocompleteController">
<select data-ng-model="mom" data-ng-options="obj.first_name+' '+obj.last_name for obj in moms track by obj.id"
selectize="{}" placeholder="{% trans "Select or type client" %}">
<option value="">{% trans "Select or type client" %}</option>
</select>
</div>
{% endblock body_content %}
/* jslint browser: true, undef: true, newcap: true, forin: true, sub: true, white: true, indent: 4, unused: false */
/* globals require: true, Settings: true, Raven: true, alert: true */
require.config({
'baseUrl': Settings.staticUrl,
'paths': {
'angular': 'angular/angular.min',
'angularAMD': 'angularAMD/angularAMD.min',
'angular-mm-foundation': 'angular-foundation/mm-foundation-tpls.min',
'json': 'libs/json2',
'modernizr': 'foundation/js/vendor/modernizr',
'jquery': 'jquery/dist/jquery.min',
//'selectize': 'selectize/dist/js/standalone/selectize',
'selectize-ng': 'selectize-ng/dist/standalone/selectize-ng',
'app': 'js/app',
'controllers': 'js/app/controllers',
'directives': 'js/app/directives',
'filters': 'js/app/filters',
'services': 'js/app/services',
},
shim: {
//'angular': {
// 'deps': ['jquery'],
// 'exports': 'angular'
//},
'angularAMD': ['angular'],
'angular-mm-foundation': {
'deps': ['angular']
},
'selectize-ng': {
'deps': ['jquery'],
}
}
});
require([
'require',
'angularAMD',
'app/app',
'app/setup', //starts the app. Notthing more is required!
], function(
require,
angularAMD,
App
){
"use strict";
Raven.config('', {
'whitelistUrls': [/arabel\.la/]
}).install();
var start = function(){
angularAMD.bootstrap(App);
};
if (Raven && Raven.lastEventId) {
try {
start();
} catch(e) {
Raven.captureException(e);
alert('Something went wrong, check Sentry log: ' + Raven.lastEventId());
}
} else {
start();
}
}
);
/* jslint browser: true, undef: true, newcap: true, forin: true, sub: true, white: true, indent: 4, unused: false */
/* globals require: true, Settings: true, Raven: true, alert: true */
require([
'angularAMD',
'app/app',
], function(
angularAMD,
App
){
"use strict";
var controller = App.controller('MomsAutocompleteController', function($scope, $http){
$scope.moms = [];
$scope.mom = {};
var responsePromise = $http.get("/api/moms/");
responsePromise.success(function(data, status, headers, config) {
console.log(data);
$scope.moms = data.results;
});
});
return controller;
}
);
/* jslint browser: true, undef: true, newcap: true, forin: true, sub: true, white: true, indent: 4, unused: false */
/* globals require: true, Settings: true, Raven: true, alert: true */
require([
'angularAMD',
'app/app',
'controllers/moms-autocomplete--controller',
], function(
angularAMD,
App
){
"use strict";
/**
* No action is required. Enough is simply to add dependence to require.
*/
return {};
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment