Question: When I log the id it shows me the correct id. I want to pass this id in the second url and fetch data accordingly. 

Like when the id is 9 and when i put it like this `url: &room_type=9&day=1` it works but not when I use it this way `url: '&room_type=' +$scope.id + '&day=1'`

```
        $http({
            method:'GET',
            url: '&hotel_id=' +$scope.current_Hotel.hotel_id
        }).then(function(response){
            var roomdata = response.data;
            $scope.roomdata = roomdata;
            var roomtype = roomdata.data;
            angular.forEach(roomtype, function(value, key){
                var id = value.room_type_id;
                $scope.id = id;
                console.info(id);
            });
        });

        $http({
            method:'GET',
            url: '&room_type=' +$scope.id + '&day=1'
        }).then(function(response){
            var plan = response.data;
            $scope.plan = plan;
        });

```

Answer: 
Here’s what you’re doing:

```
a = [1,2,3]

```

Create new list object. Create name `a` pointing to it.

```
c = a[:]

```

Create copy of list object. Create name `c` pointing to it.

```
del c

```

Delete name `c`. The object it used to point to is now garbage and will be collected eventually. This has no effect on the first object.

```
print a

```

Print what `a` points to, the first object.

```
del a[:]

```

Delete all elements of the object that `a` points to. It is now an empty list.

```
print a

```

Print the empty list.

So, what’s the difference between these lines?

```
del c
del a[:]

```

The first line removes a name from the namespace. The second line
removes elements from an object.

Edit: I see, you’re not clear on why they act that way. From [Python Language Reference, Section 6.5](https://docs.python.org/2/reference/simple_stmts.html#the-del-statement):

> Deletion of a name removes the binding of that name from the
> local or global namespace, depending on whether the name occurs in a
> `global` statement in the same code block. If the name is unbound, a
> `NameError` exception will be raised.

That’s what happens when you run `del c`.

> Deletion of attribute references, subscriptions and slicings is passed to the primary object involved; deletion of a slicing is in general equivalent to assignment of an empty slice of the right type (but even this is determined by the sliced object).

That’s what happens when you run `del a[:]`.
From the doc:

> 
> list.clear() Remove all items from the list. Equivalent to del a[:].
> 
> 
> 

`del a[:]` equals `a.clear()`

You can try to print `id(a)` and `id(c)`,they're different objects.