Learning AngularJS from a book and there was an example of simple Protractor test:

```
    it('Should redirect to #/posts/1/sample-title1', function () {
        var posts = element.all(by.repeater('post in posts'));
        posts.first().then(function (postElem) {
            postElem.findElement(by.tagName('a')).then(function (a) {
                a.click(); 
                expect(protractor.getCurrentUrl()).toMatch('/posts/1/sample-title1');
            });
        });
    });

```

It didn't work and threw an error: Failed: undefined is not a function

Not sure what was wrong, dig into the Protractor documentation and figured out a solution that work, which is:

```
it('Should redirect to #/posts/1/sample-title1', function () {
    var link = element.all(by.repeater('post in posts')).first().element(by.tagName('a'));
    link.click();
    expect(browser.getCurrentUrl()).toMatch('/posts/1/sample-title1');
  });
});

```

I'm happy that it works, however I don't quite understand why it work, still the documentation isn't very helpful here (or I'm just too tired at the moment).

Seems that I don't understand the difference between .findElement and .element

When I change the line:

```
var link = element.all(by.repeater('post in posts')).first().element(by.tagName('a'));

```

To:

```
var link = element.all(by.repeater('post in posts')).first().getWebElement().findElement(by.tagName('a'));

```

It also works, however it doesn't work when it's:

```
var link = element.all(by.repeater('post in posts')).first().findElement(by.tagName('a'));

```

Can someone explain this ? Thanks in advance !