This repository was archived by the owner on Mar 7, 2023. It is now read-only.
forked from angular/angular-seed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca3bba6
commit 209f4f6
Showing
9 changed files
with
77 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
'use strict'; | ||
function NavCtrl($scope, $location) { | ||
'use strict'; | ||
|
||
function NavCtrl($scope, $location) { | ||
$scope.isUrl = function (path, className) { | ||
if ($location.path() == path) { | ||
if ($location.path() === path) { | ||
return className; | ||
} else { | ||
return ""; | ||
} | ||
} | ||
return ""; | ||
}; | ||
|
||
$scope.hasUrl = function (path, className) { | ||
if ($location.path().substring(0, path.length) == path) { | ||
if ($location.path().search(path) === 0) { | ||
return className; | ||
} else { | ||
return ""; | ||
} | ||
} | ||
} | ||
return ""; | ||
}; | ||
} | ||
NavCtrl.$inject = ['$scope', '$location']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
function ProjectCreateCtrl($scope, $location, Project) { | ||
'use strict'; | ||
|
||
$scope.save = function () { | ||
Project.save($scope.project, function (project) { | ||
$location.path('/project'); | ||
}); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
function ProjectListCtrl($scope, Project) { | ||
'use strict'; | ||
|
||
$scope.projects = Project.query(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
function SignInCtrl($scope) { | ||
$scope.signIn = function() { | ||
'use strict'; | ||
|
||
$scope.signIn = function () { | ||
alert('Sign in of ' + $scope.name); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,37 @@ | ||
'use strict'; | ||
/*global beforeEach describe expect inject it NavCtrl */ | ||
describe('NavCtrl', function () { | ||
'use strict'; | ||
|
||
var controller, path, location, scope; | ||
|
||
beforeEach(inject(function ($rootScope, $controller) { | ||
path = undefined; | ||
location = { | ||
path: function () { | ||
return path; | ||
} | ||
}; | ||
scope = $rootScope.$new(); | ||
controller = $controller(NavCtrl, { $scope: scope, $location: location }); | ||
})); | ||
|
||
it('Should return an empty string when url does not match.', function () { | ||
path = 'url1'; | ||
expect(scope.isUrl('url2', 'className1')).toEqual(''); | ||
}); | ||
|
||
it('Should return the className when url does match.', function () { | ||
path = 'url1'; | ||
expect(scope.isUrl('url1', 'className1')).toEqual('className1'); | ||
}); | ||
|
||
it('Should return an empty string when current url does not start with the supplied url.', function () { | ||
path = 'url1-url'; | ||
expect(scope.hasUrl('url2', 'className1')).toEqual(''); | ||
}); | ||
|
||
it('Should return the className when current url starts with the supplied url.', function () { | ||
path = 'url1-url'; | ||
expect(scope.hasUrl('url1', 'className1')).toEqual('className1'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
describe('ProjectListCtrl', function () { | ||
'use strict'; | ||
|
||
var controller, scope; | ||
|
||
beforeEach(inject(function ($rootScope, $controller, $httpBackend) { | ||
scope = $rootScope.$new() | ||
controller = $controller(ProjectListCtrl, { $scope: scope, Project: Project }); | ||
})); | ||
|
||
//it('Should query for all projects and assign it to projects.', function () { | ||
|
||
//}); | ||
}); |