Destan Sarpkaya @ KodGemisi
Teknik kısıt yok ama ...
Verimlilik ve sürdürülebilirlik önemli
“İnsanlar için kod yazın, makinalar için değil.”
function ProfileCtrl($scope) {
$scope.reset = function() {
$scope.user = {};
};
$scope.getUser = function() {
$scope.user = {...};
}
}
Bir şey yok...
- {{skill.name}}
Selam {{adiniz}}!
...
angular.module('myApp', ['ngResource', 'videoPlayer'])
angular.module('myApp', ['ngResource', 'videoPlayer'])
.constant('ENDPOINT', 'https://api.kodgemisi.com/v2/')
.factory('UserSyncService', ['$scope', 'ENDPOINT', function($scope, ENDPOINT){
...
}])
.controller('ProfileCtrl', ['$scope', 'UserSyncService', function($scope, userSyncService){
...
}])
Root scope: {{data}}
1. Controller: {{data}}
2. Controller: {{data}}
angular.module('SampleForDirective', [])
.directive('toggle', function() {
return function(scope, element, attrs) {
element.addClass('btn-success').text('Açık');
var on = true;
element.on('click', function() {
if(on)
element.removeClass('btn-success').addClass('btn-danger').text('Kapalı');
else
element.removeClass('btn-danger').addClass('btn-success').text('Açık');
on = !on;
});
};
});
describe('Test showcase', function() {
describe('ProfileCtrl', function(){
it('should instantiate "users" model with 2 users', function() {
var scope = {};
var ctrl = new ProfileCtrl(scope);
expect(scope.users.length).toBe(2);
});
});
});
$ karma start karma-config.js
INFO [karma]: Karma v0.10.5 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chromium 30.0.1599 (Ubuntu)]: Connected on socket GzV3EwULE_yqFCU5elUh
Chromium 30.0.1599 (Ubuntu): Executed 1 of 1 SUCCESS (0.14 secs / 0.023 secs)
Chromium 30.0.1599 (Ubuntu) Test showcase ProfileCtrl should instantiate "users" model with 2 users FAILED
Expected 0 to be 2.
Error: Expected 0 to be 2.
at null. (/home/destan/dev/...samples/tests.js:9:34)
$.get('http://api.kodgemisi.com/v2/user/35', function(data) {
$scope.user = data;
});
$.get('http://api.kodgemisi.com/v2/user/35', function(data) {
$scope.$apply(function(){
$scope.user = data;
});
});
$http('http://api.kodgemisi.com/v2/user/35')
.success(function(data, status) {
$scope.user = data;
})
|
|
{{user.name}}