In AngularJS can I use the ng-model and the ng-bind only in the view without involving the use of a controller?

I am pretty new to AngularJS and I found this example related to the ng-model and ng-bind directives:

<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="" %>
<%@taglib prefix="page" tagdir="/WEB-INF/tags" %>


    <jsp:attribute name="title">
        AngularJS ng-bind ng-model


    <div ng-app>

    <h1>AngularJS ng-bind ng-model</h1>
        <table class="table table-striped">
            <td><b>Username:</b></td> <td><input type="text" ng-model="username"/></td>
            <td><b>Password:</b></td> <td><input type="text" ng-model="passwords"/></td>
            <td><b>authorization:</b></td>  <td><input type="text" ng-model="authorization"/> </td>

    Hi {{ username }} welcome to Java Spring MVC Integrated with AngularJS by Google and HTML5<br/>
    You password is {{ passwords }} <br/>
    and login as <span ng-bind="authorization"></span> <br/>


So basically it seems to me that it only shows a form and that each input element is related to a model property by the ng-model attribute.

Then, in the same page, I can retrieve the values of these model property by for example an AngularJS expression like {{ username }} or using the ng-bind directive. So for example:

<span ng-bind="authorization">

it means that in this span it should show the value inserted in the input tag having ng-model="authorization"

Is it my reasoning correct?

My doubt is: in using AngularJS, can I avoid going thru a controller? I have alredy seen how to put these values inside a property of the $scope service.

For example, the input tag ng-model is a specific property of the $scope service (that in this way is associating a view to a controller).

Can I avoid going thru a controller?


If I got your question right, yes you are right and you did got it well.

That's the magic of Angular. DOM-wise you have a "minimal App" without even using a Controller.

By that you can make the DOM to show the data you are typing.

Of course in order to process it he data or do something with them you will need to have a controller, but you could even set a value to something without going thru the controller by using ng-init and set the authorization variable to whatever you want.

<div ng-init="authorization='yeah'"></div>

ng-init doc

So, YES, you can use angular that way without a controller.

(Hope I got your question..)


 ? Array Object in a scope showing empty while reading in a child html page- angular JS
 ? AngularJS - Conditional attribute not working with variable?
 ? angularjs ngmodel value with two values
 ? Iterate over subscriber
 ? Angular dynamically change ng-repeat name
 ? Use a directive to display scope value and update scope
 ? AngularJS: How do I get a variable from a $http. to another controller?
 ? How to bind a checkbox list using Angular and get all selected value from the checkbox using ng-reapet method
 ? how to save textbox values in scope variable angularjs
 ? Access ng-model value in external js