Skip to content

Instantly share code, notes, and snippets.

View gsans's full-sized avatar
🚁
Hawaii is Awesome

Gerard Sans gsans

🚁
Hawaii is Awesome
View GitHub Profile
<profile data=”user”></profile>
scope : { local_data: “=data” } //using alias
scope : { data: “=” } //abbreviation when using identical names
//Usage:
// local_data = 1;
// data = 1;
<profile id=”1"></profile>
scope : { local_id: “@id” } //using alias
scope : { id: “@” } //abbreviation when using identical names
//Usage:
// var profile_id = local_id;
// var profile_id = id;
<profile id="1"></profile>
scope : { local_id: “@id” } //using alias
scope : { id: “@” } //abbreviation when using identical names
//Usage:
// var profile_id = local_id;
// var profile_id = id;
scope: true
//Usage:
// var setting = $scope.$parent.setting;
angular.module(“myapp”, [‘pascalprecht.translate’])
.config(function ($translateProvider) {
//default language
$translateProvider.preferredLanguage(‘en’);
//fallback language if entry is not found in current language
$translateProvider.fallbackLanguage(‘es’);
//load language entries from files
$translateProvider.useStaticFilesLoader({
prefix: ‘’, //relative path Eg: /languages/
suffix: ‘.json’ //file extension
<!— html code →
<select ng-model=”selectedLanguage” ng-change=”changeLanguage()”>
<option value=”en” translate=”global_language_en”></option>
<option value=”es” translate=”global_language_es”></option>
</select>
//controller
.controller(“Controller”, function($scope, $translate) {
//variable to store selected language
$scope.selectedLanguage = $translate.proposedLanguage(); //default
<h1 translate=”title”></h1>
<h1>{{title | translate}}</h1>
<!— this is set to the DOM element →
<a href=”#” class=”myclass another” id=”1" onclick=”alert(this.id + ‘ ‘ + this.className)”>DOM element</a>
<!— this is set to the DOM element -->
<a href="#" class="myclass" another” id="1" onclick="alert(this.id + ‘ ‘ + this.className)">DOM element</a>