20steps/bricks-demo-angularjs
Clone & Install
git clone https://github.com/20steps/bricks-demo-angularjs.git
cd bricks-demo-angularjs
npm install
bower install # If using Bower (legacy)
Basic Setup
bricksDemo) in your Angular app:
angular.module('myApp', ['bricksDemo']);
First Use Case: Using a Directive
bricksDemo includes a bricksButton directive, use it in HTML:
<bricks-button text="Click Me" on-click="handleClick()"></bricks-button>
demo/ folder for example implementations.src/.angular.module('bricksDemo').service('DataService', function($http) {
this.fetchData = function() { return $http.get('/api/data'); };
});
Extending Existing Modules
angular.module('myApp').directive('bricksButton', function() {
return {
restrict: 'E',
template: '<button>{{text}}</button>',
link: function(scope, elem, attrs) {
elem.on('click', scope.$eval(attrs.onClick));
}
};
});
Customizing Templates
templateUrl to override default templates:
.directive('bricksCard', function() {
return {
templateUrl: 'path/to/custom-card.html'
};
});
State Management (UI-Router)
ui-router, integrate it with your app’s routing:
angular.module('myApp').config(function($stateProvider) {
$stateProvider.state('dashboard', {
url: '/dashboard',
templateUrl: 'dashboard.html',
controller: 'DashboardCtrl'
});
});
test/ folder).describe('Custom Bricks Directive', function() {
beforeEach(module('myApp'));
it('should render correctly', inject(function($compile, $rootScope) {
var element = $compile('<bricks-button text="Test"></bricks-button>')($rootScope);
$rootScope.$digest();
expect(element.html()).toContain('Test');
}));
});
AngularJS vs. Angular
@Component, @Injectable, etc.Bower Dependency
npm install --save bower-angularjs
Scope Issues
scope: {} may break if parent scopes change. Prefer bindToController (Angular 1.3+) or isolate scopes carefully.Missing Documentation
src/ for source code.demo/ for usage examples.README.md for high-level notes.angular.module('bricksDemo').service('Logger', function() {
this.log = function(msg) { console.log('[Bricks] ' + msg); };
});
$http calls in .catch():
DataService.fetchData().catch(function(err) {
console.error('API Error:', err);
});
Custom Directives
.directive('bricksButton', function() {
return {
restrict: 'E',
scope: {
text: '@',
onClick: '&',
customAction: '&?' // Optional
}
};
});
Service Overrides
angular.module('myApp').value('Config', {
apiUrl: 'https://my-api.com',
timeout: 10000
});
CSS Overrides
!important sparingly. Prefer BEM-style classes:
.bricks-button {
--custom-color: #ff0000;
}
.bricks-button__custom {
color: var(--custom-color);
}
Performance
angular.module('myApp').config(function($ocLazyLoadProvider) {
$ocLazyLoadProvider.config({ debug: true });
});
How can I help you explore Laravel packages today?