Question: I have the below controller function that returns me a Boolean value.

**Current HTML**:

```
<a href="#" ng-click="collapseNavbar(true)" ng-model="collNavbar">
    <i class="fa fa-arrow-right"></i>
</a>

```

**layoutController:** 

```

App.controller('layoutController', ['$scope', function($scope) {

    $scope.collapseNavbar = function(val) {

        return $scope.value = !val;

    }

}])

```

Based on that value I need to assign the `<body>` tag a class like yes or no.

Earlier I was using something like this to do it.

**HTML :**

```
<div class="toggle-sidebar navbar-nav">
     <ul class="nav navbar-nav">
        <li>
            <a href="#" ng-click="isActive = !isActive" ng-model="collNavbar">
                <i class="fa fa-arrow-right"></i>
            </a>
        </li>
    </ul>
</div>

```

**HTML2**

```
<body ng-class="{'yes': isActive, 'no': !isActive}" ng-controller="layoutController">

```

But I don't want my code to be in the HTML file. Instead I created a controller for it named `layoutController.js` and above is the code used in it.

I'm able to pass the Boolean as a class to the `body` tag on pageload. 

But I don't know how to pass it on a click of the `a` tag where as I've passed the function using `ng-click`.

Any suggestions like how can I do it will be very helpful for me in the learning it.

Thanks in advance.

Answer: 
In beta 4, Swift's String.Index handling changed yet again -- you now can't supply an `Int` when a `String.Index` is expected. The way to handle it is by creating the `String.Index` you need using the `advance` method:

```
if !name.isEmpty {
    var splitted: [String] = name.componentsSeparatedByString(" ")

    for curPart in splitted {
        if !curPart.isEmpty {
            acronym += curPart.substringToIndex(advance(curPart.startIndex, 1))
        }
    }
    if countElements(acronym) > 2 {
        acronym = acronym.substringToIndex(advance(acronym.startIndex, 2))
    }
}

```

This is all based on making sure Unicode strings are handled properly - since different Unicode characters can have different sizes, pure integer indexing would hide the fact that Strings aren't random access.
**For Swift 2.0**

Using the example above:

```
curPart.substringToIndex(curPart.startIndex.advancedBy(1)) 

```