mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-04-18 22:01:01 +00:00
fix(ngController): fix indentation bug which causes example to mess up
This commit is contained in:
parent
c38073667d
commit
b6a0777b24
1 changed files with 23 additions and 26 deletions
|
|
@ -35,32 +35,32 @@
|
|||
<doc:example>
|
||||
<doc:source>
|
||||
<script>
|
||||
function SettingsController() {
|
||||
function SettingsController1() {
|
||||
this.name = "John Smith";
|
||||
this.contacts = [
|
||||
{type: 'phone', value: '408 555 1212'},
|
||||
{type: 'email', value: 'john.smith@example.org'} ];
|
||||
};
|
||||
|
||||
SettingsController.prototype.greet = function() {
|
||||
SettingsController1.prototype.greet = function() {
|
||||
alert(this.name);
|
||||
};
|
||||
|
||||
SettingsController.prototype.addContact = function() {
|
||||
SettingsController1.prototype.addContact = function() {
|
||||
this.contacts.push({type: 'email', value: 'yourname@example.org'});
|
||||
};
|
||||
|
||||
SettingsController.prototype.removeContact = function(contactToRemove) {
|
||||
SettingsController1.prototype.removeContact = function(contactToRemove) {
|
||||
var index = this.contacts.indexOf(contactToRemove);
|
||||
this.contacts.splice(index, 1);
|
||||
};
|
||||
|
||||
SettingsController.prototype.clearContact = function(contact) {
|
||||
SettingsController1.prototype.clearContact = function(contact) {
|
||||
contact.type = 'phone';
|
||||
contact.value = '';
|
||||
};
|
||||
</script>
|
||||
<div ng-controller="SettingsController as settings">
|
||||
<div id="ctrl-as-exmpl" ng-controller="SettingsController1 as settings">
|
||||
Name: <input type="text" ng-model="settings.name"/>
|
||||
[ <a href="" ng-click="settings.greet()">greet</a> ]<br/>
|
||||
Contact:
|
||||
|
|
@ -79,29 +79,26 @@
|
|||
</div>
|
||||
</doc:source>
|
||||
<doc:scenario>
|
||||
it('should check controller', function() {
|
||||
expect(element('.doc-example-live div>:input').val()).toBe('John Smith');
|
||||
expect(element('.doc-example-live li:nth-child(1) input').val())
|
||||
it('should check controller as', function() {
|
||||
expect(element('#ctrl-as-exmpl>:input').val()).toBe('John Smith');
|
||||
expect(element('#ctrl-as-exmpl li:nth-child(1) input').val())
|
||||
.toBe('408 555 1212');
|
||||
expect(element('.doc-example-live li:nth-child(2) input').val())
|
||||
expect(element('#ctrl-as-exmpl li:nth-child(2) input').val())
|
||||
.toBe('john.smith@example.org');
|
||||
|
||||
element('.doc-example-live li:first a:contains("clear")').click();
|
||||
expect(element('.doc-example-live li:first input').val()).toBe('');
|
||||
element('#ctrl-as-exmpl li:first a:contains("clear")').click();
|
||||
expect(element('#ctrl-as-exmpl li:first input').val()).toBe('');
|
||||
|
||||
element('.doc-example-live li:last a:contains("add")').click();
|
||||
expect(element('.doc-example-live li:nth-child(3) input').val())
|
||||
element('#ctrl-as-exmpl li:last a:contains("add")').click();
|
||||
expect(element('#ctrl-as-exmpl li:nth-child(3) input').val())
|
||||
.toBe('yourname@example.org');
|
||||
});
|
||||
</doc:scenario>
|
||||
</doc:example>
|
||||
|
||||
|
||||
|
||||
<doc:example>
|
||||
<doc:source>
|
||||
<script>
|
||||
function SettingsController($scope) {
|
||||
function SettingsController2($scope) {
|
||||
$scope.name = "John Smith";
|
||||
$scope.contacts = [
|
||||
{type:'phone', value:'408 555 1212'},
|
||||
|
|
@ -126,7 +123,7 @@
|
|||
};
|
||||
}
|
||||
</script>
|
||||
<div ng-controller="SettingsController">
|
||||
<div id="ctrl-exmpl" ng-controller="SettingsController2">
|
||||
Name: <input type="text" ng-model="name"/>
|
||||
[ <a href="" ng-click="greet()">greet</a> ]<br/>
|
||||
Contact:
|
||||
|
|
@ -146,17 +143,17 @@
|
|||
</doc:source>
|
||||
<doc:scenario>
|
||||
it('should check controller', function() {
|
||||
expect(element('.doc-example-live div>:input').val()).toBe('John Smith');
|
||||
expect(element('.doc-example-live li:nth-child(1) input').val())
|
||||
expect(element('#ctrl-exmpl>:input').val()).toBe('John Smith');
|
||||
expect(element('#ctrl-exmpl li:nth-child(1) input').val())
|
||||
.toBe('408 555 1212');
|
||||
expect(element('.doc-example-live li:nth-child(2) input').val())
|
||||
expect(element('#ctrl-exmpl li:nth-child(2) input').val())
|
||||
.toBe('john.smith@example.org');
|
||||
|
||||
element('.doc-example-live li:first a:contains("clear")').click();
|
||||
expect(element('.doc-example-live li:first input').val()).toBe('');
|
||||
element('#ctrl-exmpl li:first a:contains("clear")').click();
|
||||
expect(element('#ctrl-exmpl li:first input').val()).toBe('');
|
||||
|
||||
element('.doc-example-live li:last a:contains("add")').click();
|
||||
expect(element('.doc-example-live li:nth-child(3) input').val())
|
||||
element('#ctrl-exmpl li:last a:contains("add")').click();
|
||||
expect(element('#ctrl-exmpl li:nth-child(3) input').val())
|
||||
.toBe('yourname@example.org');
|
||||
});
|
||||
</doc:scenario>
|
||||
|
|
|
|||
Loading…
Reference in a new issue